SMTP server that needs to be verified using System.Web.mail namespace

xiaoxiao2021-03-06  36

Just add the corresponding ID: // Use the SMTPMAIL object to send mail mailMessage mailobj = new mailmessage ();

Mailobj.fields.Add ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate," 1 "); // Setup Requires Verification Mailobj.fields.Add (" http://schemas.microsoft.com / cdo / configure / sendusername ", username); // User name Mailobj.fields.add (" http://schemas.microsoft.com/cdo/configuration/sendpassword ", password); // password

-------------- Example Function --------------- Public Void Sendmail (String Subject, String Txt, String Mailserver, String Username, String Password, String from, string sendto) {mailmessage mailobj = new mailmessage ();

// Set the send and receive address mailobj.from = from; mailobj.to = sendto;

Mailobj.Subject = Subject; Mailobj.Body = txt;

// HTML format mail mailobj.bodyFormat = mailformat.html;

// Set to advanced priority mailobj.priority = mailpriority.high;

// Add an attachment // to send an attachment // Use the ATTachments collection Add method to create a MaiLattachment object Add an attachment to the message //mailobj.attachments.add(new MaiLattachment ("c: //test.doc");

// Send mail mailbobj.fields.add ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); // Setup Requirements Mailobj.fields.Add ("http: //schemas.microsoft.com/cdo/configuration/sendusername ", username); // User name Mailobj.fields.add (" http://schemas.microsoft.com/cdo/configuration/sendpassword ", password); / /password

SMTPMAIL.SMTPSERVER = MailServer; SMTPMAIL.SEND (Mailobj);

// Call the sample private void button1_click (object sender, system.eventargs e) {try {

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

New Post(0)