使用 System.Web.Mail发送邮件
2018-09-06 11:08
//simpleemail
mail.Subject=thisisatestemail.;
mail.Body=thisismytestemailbody;
SmtpMail.SmtpServer=localhost;//yourrealservergoeshere
SmtpMail.Send(mail);
//simpleHtmlemail
mail.To=me@mycompany.com;
mail.From=you@yourcompany.com;
mail.Subject=thisisatestemail.;
mail.BodyFormat=MailFormat.Html;
mail.Body=thisismytestemailbody.<br><b>thispartisinbold</b>;
SmtpMail.SmtpServer=localhost;//yourrealservergoeshere
SmtpMail.Send(mail);
//emailwithattachments
MailMessagemail=newMailMessage();
mail.To=me@mycompany.com;
mail.From=you@yourcompany.com;
mail.Subject=thisisatestemail.;
mail.Body=thisismytestemailbody.;
MailAttachmentattachment=newMailAttachment(Server.MapPath(test.txt));//createtheattachment
mail.Attachments.Add(attachment);//addtheattachment
SmtpMail.SmtpServer=localhost;//yourrealservergoeshere
SmtpMail.Send(mail);
//changetheTOaddresstoafriendlyname
mail.From=JohnSmith<you@yourcompany.com>;
//multiplerecipients
mail.To=me@mycompany.com;him@hiscompany.com;her@hercompany.com;
aspx
文章标题:使用 System.Web.Mail发送邮件
文章链接:http://soscw.com/index.php/essay/9060.html