如何更改电子邮件发件人地址字段?
我试图用姓名和电子邮件地址更改 FROM 字段。但是当我收到电子邮件时,如下所示
My network <[email protected] [My network <[email protected]]
我的代码如下所示
const string from = "My network <[email protected]>";
StringDictionary headers = new StringDictionary();
headers.Add("to", invitee.userEmail);
headers.Add("subject", ltEmailSubject.Text);
headers.Add("from", from);
headers.Add("content-type", MediaTypeNames.Text.Html);
_emailSuccessful = SPUtility.SendEmail(elevatedSite.RootWeb, headers,
emailBody + Environment.NewLine + "");
我希望发件人电子邮件地址应显示如下
My network [[email protected]]
I was trying to change FROM field with Name and Email address. But When I receive the email, Its shown as below
My network <[email protected] [My network <[email protected]]
Mycode is like below
const string from = "My network <[email protected]>";
StringDictionary headers = new StringDictionary();
headers.Add("to", invitee.userEmail);
headers.Add("subject", ltEmailSubject.Text);
headers.Add("from", from);
headers.Add("content-type", MediaTypeNames.Text.Html);
_emailSuccessful = SPUtility.SendEmail(elevatedSite.RootWeb, headers,
emailBody + Environment.NewLine + "");
I want FROM email address should showup like below
My network [[email protected]]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
SPUtility.SendMail 将始终使用管理中心 > 中指定的发件人 smtp 地址。发送电子邮件设置和友好名称设置为站点的标题。
相反,您可以使用(来自 http://www.systemnetmail.com/faq/3.2. 1.aspx)
SPUtility.SendMail will always use the from smtp address as specified in Central Administration > Outgoing Email Settings and the friendly name is set to the title of the site.
Instead you can use (from http://www.systemnetmail.com/faq/3.2.1.aspx)
我知道这个线程很旧,但万一有人像我一样遇到这个问题,如果您在发件人地址中的友好名称周围添加引号,那么您的原始代码可以使用 SPUtility.SendMail 正常工作,如下所示:
I know this thread is old, but in case someone comes across this as I did, your original code would have worked fine using SPUtility.SendMail if you added quotes around the friendly name in the from address like this:
我相信如果您查看 .Net Framework 中的邮件对象,您可以做您想做的事情。
也许这个网站可以进一步帮助您?
I believe if you look at the mail object in the .Net Framework, you could do what you wish to do.
Maybe this site could help you out further?