在asp.net中发送电子邮件 [英] Email Sending in asp.net
本文介绍了在asp.net中发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用c#在asp.net中发送邮件时,如何在姓氏和姓氏上替换电子邮件地址?
类似于来自:Nilesh Deokar",而不是来自:nileshdeokar@gmail.com".
How to put Firstname and Lastname in place of email address while sending mail in asp.net using c# ?
Like " From : Nilesh Deokar " in place of " From : nileshdeokar@gmail.com "
推荐答案
检查此链接
在asp.net中发送电子邮件 [
Hi ,
Check this link
sending emails in asp.net[^]
Best Regards
M.Mitwalli
尝试以下操作:
创建一个MailAddress
类的实例,该实例将分配给To属性.然后为其分配DisplayName属性.
示例:
Try the following:
Create an instance ofMailAddress
class that will be assigned to To property. Then assign to it the DisplayName property.
Example:
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
MailAddress from = new MailAddress("ben@contoso.com", "Ben Miller");
from.DisplayName = "My name";
message.From = from;
// Send SMTP mail
smtpClient.Send(message);
您还可以在这里找到更多信息:
http://msdn.microsoft.com/en-us/library/system. net.mail.mailaddress.aspx [ ^ ]
欢呼
You can also find more info here:
http://msdn.microsoft.com/en-us/library/system.net.mail.mailaddress.aspx[^]
Cheers
您可以使用EmailAddress类的DisplayName属性或在构造函数中提供显示名称.
http://msdn.microsoft.com/en-us/library/system.net.mail.mailaddress.displayname.aspx [ ^ ]
You can use the DisplayName property of the EmailAddress class or provide the display name in the constructor.
http://msdn.microsoft.com/en-us/library/system.net.mail.mailaddress.displayname.aspx[^]
MailAddress from = new MailAddress"ben@contoso.com", "Ben Miller");
MailAddress to = new MailAddress("jane@contoso.com", "Jane Clayton");
MailMessage message = new MailMessage(from, to);
message.Subject = "Using the SmtpClient class.";
message.Body = @"This is the body of this email.";
SmtpClient client = new SmtpClient(serveraddress);
try
{
client.Send(message);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
问候,
杰拉尔德
Regards,
Gerald
这篇关于在asp.net中发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文