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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With