Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Don't show "Display Name" at sending e-mail

Tags:

c#

.net

iis-7

smtp

I send mail from my site (.NET Framework 2.0, IIS 7) as

MailAddress from = new MailAddress("[email protected]", "Name Name");
MailAddress to = new MailAddress("[email protected]", "");
MailMessage mm = new MailMessage(from, to);
mm.Subject = subject;
mm.Body = body;
using ( mm )
{
    if (attach != null)
        mm.Attachments.Add(attach);
    mm.IsBodyHtml = true;

    SmtpClient smtp = new SmtpClient(mailServer);
    if (!string.IsNullOrEmpty(mailPort))
        smtp.Port = int.Parse(mailPort);
    smtp.Credentials = new System.Net.NetworkCredential(username, pass);
    smtp.Send(mm);
}

But there is no Display Name ("Name Name") at getting letter, only e-mail.

Do you have any idea of what could cause this issue?

I'm sure, the email client isn't ignoring the display name! Client is Outlook.

When application transfer object mm to the server, property From is {"Name Name" <[email protected]>}. Why does server remove name?

like image 363
iodum Avatar asked Jun 10 '11 02:06

iodum


People also ask

How do I hide my name when sending an email in Outlook?

When you open a new blank email in Outlook, click on the “Options” tab. From there, you'll want to select the Bcc field in the message header. This is your “blind carbon copy” option, meaning that your email recipients will not see other names on the list.

Does your name show when you send an email?

Overview. When you send an email, the display name that appears next to your email address is called the Sender info. In Front, Sender info is tied to the signature that you use when sending an email. It can be changed in your signature settings at any time.

How do I change the name that shows up when I send an email Microsoft?

In Outlook, choose File > Account Settings > Account Settings. Select the email account that you want to change, and then choose Change. You can change your name on the Account Settings screen. To change the name that displays when you send email, update the Your name field.


1 Answers

I've had trouble with this issue as well, but found that MailAddress also takes a third encoding argument. So instead of using:

MailAddress from = new MailAddress("[email protected]", "Name Name");

Try some of these guys:

MailAddress from = new MailAddress("[email protected]", "Name Name", Encoding.ASCII);
MailAddress from = new MailAddress("[email protected]", "Name Name", Encoding.UTF8);
MailAddress from = new MailAddress("[email protected]", "Name Name", Encoding.Unicode);

This list is not limiting, there are other encoding options you can use. I use gmail and after enabling the access for Less Secure Apps, it works for all of these after using the SmtpClient.

like image 53
mcataldi Avatar answered Sep 20 '22 20:09

mcataldi