Send an email with System.Web.mail

xiaoxiao2021-03-06  40

Send an email with System.Web.mail

private static int GoToSendMail (string Body, string To) {try {System.Web.Mail.MailMessage mm = new System.Web.Mail.MailMessage (); mm.BodyFormat = System.Web.Mail.MailFormat.Html; mm. From = "

Xxx@xxx.com

"; Mm.to = TO; mm.bodyencoding = system.text.encoding.getencoding (936); mm.subject =" Hello! I am a dream cat. Net studio hopes to work with you. "Mm.body = body; mm.fields ["

http://schemas.microsoft.com/cdo/configuration/sendusing

"] = 2; mm.fields ["

http://schemas.microsoft.com/cdo/configuration/sendemailaddress

"] ="

Xxx@xxx.com "; //

Send the address; if mm.from wrote this, you can do this mm.fields ["

http://schemas.microsoft.com/cdo/configuration/smtpaccountname

"] ="

Xxx@xxx.com

"; Mm.fields ["

http://schemas.microsoft.com/cdo/configuration/sendusername

"] =" Xxx "; // Verify account: sender mailbox account mm.fields ["

http://schemas.microsoft.com/cdo/configuration/sendpassword

"] =" Xxx "; // Verify password: sender mailbox password mm.fields ["

http://schemas.microsoft.com/cdo/configuration/smtpauthenticate

"] = 1; // Verification level 0,1,2 mm.fields ["

http://schemas.microsoft.com/cdo/configuration/languagecode

"] = 0x0804; // Language code mm.fields ["

http://schemas.microsoft.com/cdo/configuration/smtpserver

"] ="

SMTP.XXX.com

"; // SMTP server system.web.mail.smtpmail.smtpserver ="

SMTP.XXX.com

"//

The above sentence is heavy, this sentence can replace the upper sentence system.Web.mail.smtpmail.send (mm); return 0;} catch (system.exception e) {response.write (E.MESSAGE E.STACKTRACE E.Source); Return -1;}}

转载请注明原文地址:https://www.9cbs.com/read-55475.html

New Post(0)