如何仅显示displayname而不是电子邮件地址 [英] How to show only displayname instead of email address
本文介绍了如何仅显示displayname而不是电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用下面的代码来显示显示名称,但现在它在outlook中显示为示例[example@abc.com]。是否可以在发件人地址中仅显示显示名称
I have used the below code to show display name, but now its displaying as example[example@abc.com] in outlook. Is it possible to show only display name in From address
MailMessage mail = new MailMessage();
mail.To.Add(new MailAddress(mailPropObj.ToAddress.ToString()));
mail.From = new MailAddress(example@abc.com,"example");
有没有人有解决方案?
Does anyone have a solution?
推荐答案
使用符号< >以及电子邮件和名称如下
Use symbols < > along with email & name like below
System.Net.Mail.MailMessage Mail = new System.Net.Mail.MailMessage("example<example@abc.com>", "a@a.com", Subject, Message);
使用对于这一行。不要添加net.mail命名空间
myMail.From = new System.Net.Mail.MailAddress(From1,EmailFromName).ToString();
use this for this line. don't add net.mail namespace
myMail.From = new System.Net.Mail.MailAddress(From1, EmailFromName).ToString();
这篇关于如何仅显示displayname而不是电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文