C # How to send an email?

xiaoxiao2021-03-06  77

Easy, TOO EASY;

-------------------- CODE ---------------------

Private void sendmill_net () {//.NET SMTP class for mail delivery, support authentication, attachment added; system.Web.mail.mailMersage mailmsg = new system.web.mail.mailMASTEM.WEB.MAIL.MAILMESSAGE (); mailmsg.from = this.tb_from. Text.trim (); Mailmsg.to = this.tb_to.text.trim (); mailmsg.body = this.tb_mailbody.text.trim (); mailmsg.subject = "test mail from hz"; / * Paste , ^ _ ^, Stupid; if (this.att1.value.tostring (). Trim ()! = String.empty) Mailmsg.attachments.add (new system.Web.mail.MaiLattachment (this.att1.value .Tostring (). Trim ())); if (this.att2.value.tostring (). Trim ()! = String.empty) Mailmsg.attachments.add (new system.Web.mail.maiLattachment (this.att2 .Value.toString (). Trim ())); if (this.att3.value.tostring (). Trim ()! = String.empty) mailmsg.attachments.add (new system.web.mail.maiLattachment (THIS .att3.value.toString (). Trim ())); * / mailmsg.fields.add ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate," 1 "); // Need Verify, generally must be Mailmsg.fields.Add ("http://schemas.microsoft.com/cdo/configuration/sendusername", "GAL LON_HAN "); // User name Mailmsg.fields.add (" http://schemas.microsoft.com/cdo/configuration/sendpassword "," http://schemas.microsoft.com/cDo/configuration/sendpassword "," http://schemas.microsoft.com/cdo/configuration/sendpassword "," 91900 "); // The password of your own mailbox System.Web. Mail.smtpmail.smtpserver = this.tb_smtpserver.text.trim (); System.Web.mail.smtpmail.send (Mailmsg);} -------------------- Supplement -------- When the mail group is issued, you can use "," to split the list of email, and then assign MailMessage .bcc (instead of MailMessage .to) OK.

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

New Post(0)