How do I change the FROM address to a friendly name?
2005-03-13 17:21
796 查看
By default, many people set the FROM property of the MailMessage class to something like: mail.From = "me@mycompny.com"By doing this the email address will show up in the FROM line of most email readers, such as Outlook, Outlook Express, or Eudora. To have a friendly name be displayed (instead of the email address), use the following syntax. mail.From = "/"John Smith/" <me@mycompny.com>"The following code snippet demonstrates this technique.
[ C# ]
[ VB.NET ]
[ C# ]
MailMessage mail = new MailMessage(); mail.To = "me@mycompany.com"; mail.From = "/"John Smith/" <you@yourcompany.com>"; mail.Subject = "this is a test email."; mail.Body = "this is my test email body."; SmtpMail.SmtpServer = "localhost"; //your real server goes here SmtpMail.Send( mail );
[ VB.NET ]
Dim mail As New MailMessage() mail.To = "me@mycompany.com" mail.From = """John Smith"" <you@yourcompany.com>" mail.Subject = "this is a test email." mail.Body = "this is my test email body." SmtpMail.SmtpServer = "localhost" 'your real server goes here SmtpMail.Send(mail)
相关文章推荐
- How to Change the Hostname of a Linux System
- Ubuntu: How to Change the Computer Name
- How to Change the Hostname of a Linux System
- In an iOS 5 Storyboard, how do you push a new scene to the original view controller from a Popover?
- HOWTO get multiple value from the same name checkbox elements or radiobution elements
- How to Delete an Address from the Outlook Auto-Complete List
- FAQ How do I write to the console from a plug-in?
- How to use the BAPI_BUPA_ADDRESS_CHANGE
- How do you copy the contents of an array to a std::vector in C++ without looping? (From stack over flow)
- How to change the language of oracle sqlplus from chinese to english in windows(如何将oracle sql plus中的中文变成英文版)
- How to change the property of a control from a flowlayoutpanel?
- How to change the computer name on Ubuntu
- Ubuntu: How to Change the Computer Name
- How do I use a host name to look up an IP address?
- (Django) How do I set limit_choices_to another class from where the ManyToManyField points to? - django, django-models - TechQues.com
- How to change the name of logfile dynamically using log4j
- FAQ How do I write to the console from a plug-in?
- How To Let Users Change Their Email Address in TheBeerHouse Starter Kit
- How do I fix the linker error in project upgraded from VS2010 to VS2013 where the linker is looking
- Understanding Object Ownership in sql 2000(how to change the schema table name in sql 2000)