using System.Web.Mail to send email
2007-09-02 11:11
441 查看
there are many demos for send a email with c sharp language .however,you will find that most of them will be failed because of SMTPServer.Especially,authorization is required.
public void SendEMail()
...{
MailMessage mail = new MailMessage();
mail.Priority = MailPriority.High;
mail.From = "cccc@gmail.com";
mail.To = "cccc@163.com";
mail.Subject = "Send EMail System Demo";
mail.Body = "Just for test.";
mail.BodyEncoding = Encoding.UTF8;
// authorization
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 1);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendemailaddress", mail.From);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpuserreplyemailaddress", mail.From);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpaccountname", "cccc@163.com");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "cccc");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "smtp.163.com");
SmtpMail.SmtpServer = "smtp.163.com";
SmtpMail.Send(mail);
}
#endregion
public void SendEMail()
...{
MailMessage mail = new MailMessage();
mail.Priority = MailPriority.High;
mail.From = "cccc@gmail.com";
mail.To = "cccc@163.com";
mail.Subject = "Send EMail System Demo";
mail.Body = "Just for test.";
mail.BodyEncoding = Encoding.UTF8;
// authorization
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 1);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendemailaddress", mail.From);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpuserreplyemailaddress", mail.From);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpaccountname", "cccc@163.com");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "cccc");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "smtp.163.com");
SmtpMail.SmtpServer = "smtp.163.com";
SmtpMail.Send(mail);
}
#endregion
相关文章推荐
- using System.Web.Mail to send email
- How to Send an Email Using UTL_SMTP with Authenticated Mail Server. (文档 ID 885522.1)
- How to send mail using any email account through Foxmail ? - Foxmail 6 漏洞,如何通过 Foxmail 用任意邮件账号发送邮件?
- How to Send an Email Using UTL_SMTP with Authenticated Mail Server
- How to Send an Email Using UTL_SMTP with Authenticated Mail Server
- How to Send an Email Using UTL_SMTP with Authenticated Mail Server
- HOW TO: Send email using System.Net.Mail
- How to Send an Email Using UTL_SMTP with Authenticated Mail Server
- The IP you're using to send email is not authorized
- Using exchange server to send email in Powershell
- How to send Email using C#
- Save an XML File to Database and Send an Email using XSLT
- using System.Web.Mail发送邮件
- How to send email using sqlserver
- 让国外邮件服务商不再拒收你的邮件,The IP you're using to send mail is not authorized
- How to send email via vbs using cdo
- [转]让国外邮件服务商不再拒收你的邮件,The IP you're using to send mail is not authorized
- Use Java Mail API to Send Email
- Check SMTP Server Availability for ORA-29278 or ORA-29279 errors using UTL_SMTP to Send Email
- Web上利用System.Web.Mail发送EMail