System.Net.Mail.MailAddress someMailAddress = new System.Net.Mail.MailAddress(" me@example.org ", "John Doe"); System.Console.WriteLine(someMailAddress.Address); // me@example.org System.Console.WriteLine(someMailAddress.User); // me System.Console.WriteLine(someMailAddress.Host); // example.org System.Console.WriteLine(someMailAddress.DisplayName); // John Doe System.Console.WriteLine(someMailAddress); // "John Doe" < me@example.org >
It doesn't change too much in the behavior of the string, but it provides a pretty good way to save the email address in a safe way. In addition, this object can be added to the mail message object. :)
hangy source share