简体   繁体   中英

Why there is “from” attribute of <smtp> element in <system.net><mailSettings>? How can i use it?

Why there is "from" attribute of <smtp> element in <system.net><mailSettings>? How can i use it? As far as i see, i anyway have to specify From parameter for MailMessage class constructor. Can i use "from" attribute of <smtp> element for this in any natural way?

There is an overload of the MailMessage constructor that doesn't require any parameters. This will set the From property to the value in your .config file. See here for more information, particularly the "Remarks" section:

http://msdn.microsoft.com/en-us/library/ms144707.aspx

"From is set to the value in the network element for mailSettings Element (Network Settings), if it exists."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM