使用 System.Web.Mail发送邮件
来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 11:42 点击:次
//simple email
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send( mail );
//simple Html email
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.BodyFormat = MailFormat.Html;
mail.Body = "this is my test email body.<br><b>this part is in bold</b>";
SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send( mail );
//email with attachments
MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body.";
MailAttachment attachment = new MailAttachment( Server.MapPath( "test.txt" ) ); //create the attachment
mail.Attachments.Add( attachment ); //add the attachment
SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send( mail );
//change the TO address to a friendly name
mail.From = ""John Smith" <you@yourcompany.com>";
//multiple recipients
mail.To = "me@mycompany.com;him@hiscompany.com;her@hercompany.com";
http://www.systemwebmail.com/faq/1.aspx
http://www.systemwebmail.com/faq/1.aspx
http://www.systemwebmail.com/faq/1.aspx
http://www.systemwebmail.com/faq/1.aspx
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send( mail );
//simple Html email
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.BodyFormat = MailFormat.Html;
mail.Body = "this is my test email body.<br><b>this part is in bold</b>";
SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send( mail );
//email with attachments
MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body.";
MailAttachment attachment = new MailAttachment( Server.MapPath( "test.txt" ) ); //create the attachment
mail.Attachments.Add( attachment ); //add the attachment
SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send( mail );
//change the TO address to a friendly name
mail.From = ""John Smith" <you@yourcompany.com>";
//multiple recipients
mail.To = "me@mycompany.com;him@hiscompany.com;her@hercompany.com";
http://www.systemwebmail.com/faq/1.aspx
http://www.systemwebmail.com/faq/1.aspx
http://www.systemwebmail.com/faq/1.aspx
http://www.systemwebmail.com/faq/1.aspx
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>