vb.net - SmtpMail - 将 "From Address"更改为名称

标签 vb.net email smtp

我使用SmtpMail让用户转发网站内容。用户填写包含名字和电子邮件的表格。

发送的电子邮件具有完整的电子邮件地址,作为收件人收件箱中的“发件人地址”(他们看到发件人:[email protected],而我希望他们看到发件人:Joe)。

如何将“发件人地址”格式化为用户输入的名字?

谢谢!

最佳答案

MailAddress类有一个可选参数,您可以在其中指定显示名称。我假设它存在时就会被使用。

Dim from As MailAddress = New MailAddress("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4e2c2b200e2d21203a213d21602d2123" rel="noreferrer noopener nofollow">[email protected]</a>", "Ben Miller")
Dim to As MailAddress = New MailAddress("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="81ebe0efe4c1e2eeeff5eef2eeafe2eeec" rel="noreferrer noopener nofollow">[email protected]</a>", "Jane Clayton")
Dim message As MailMessage = New MailMessage(from, to)

关于vb.net - SmtpMail - 将 "From Address"更改为名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4018427/

相关文章:

vb.net - 实例化和初始化是否仅在与按钮单击相关时才起作用?

c# - 根据类次列表创建时间表的摘要说明

asp.net - 为什么使用 HTML5 uploader 时 Request.Files.Count 有时为 0?

PHP 发送的电子邮件主题 - Hotmail/Outlook 将 £ 显示为 £

python - 如何在Python中解析带有括号的电子邮件FROM header ?

email - 电子邮件中的Google DFP广告管理系统行为异常

Python:如何更改 smtp/MIME 脚本中的 "to"字段而不是添加新字段?

c# - .NET 通用类实例 - 传递可变数据类型

grails - JavaMail SMTP主机错误

asp.net - 在 asp.net 中发送电子邮件 (Gmail)