MailMessage MailObj=new MailMessage();
MailObj.From = sender;//发件人
MailObj.To = receiver;//收件人
MailObj.Subject =subject; //邮件标题
MailObj.Priority = MailPriority.High;//邮件等级
MailObj.BodyFormat = MailFormat.Text;
MailObj.Body =body;//邮件内容
#region SMTP的注册信息
MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2;
//用smtp Server用外部的,把SendUsing外部是2,内部为1
MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/sendemailaddress"] = sender;
MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/smtpaccountname"] = sender;
MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = sender;
MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = sendPassword;
#region 是否验证SMTP
//value=0 代表Anonymous验证方式(不需要验证)
//value=1 代表Basic验证方式(使用basic (clear-text) authentication.
//Value=2 代表NTLM验证方式(Secure Password Authentication in Microsoft Outlook Express)
MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 0;
// if(Mail.nSmtpAuthenticate != 0 )
// {
// MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = Mail.nSmtpAuthenticate;
// }
#endregion
//已经约定的格式
MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/languagecode"] = 0x0804;
MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"] = "smtpServer";
#endregion
SmtpMail.Send(MailObj);
MailObj.From = sender;//发件人
MailObj.To = receiver;//收件人
MailObj.Subject =subject; //邮件标题
MailObj.Priority = MailPriority.High;//邮件等级
MailObj.BodyFormat = MailFormat.Text;
MailObj.Body =body;//邮件内容
#region SMTP的注册信息
MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2;
//用smtp Server用外部的,把SendUsing外部是2,内部为1
MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/sendemailaddress"] = sender;
MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/smtpaccountname"] = sender;
MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = sender;
MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = sendPassword;
#region 是否验证SMTP
//value=0 代表Anonymous验证方式(不需要验证)
//value=1 代表Basic验证方式(使用basic (clear-text) authentication.
//Value=2 代表NTLM验证方式(Secure Password Authentication in Microsoft Outlook Express)
MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 0;
// if(Mail.nSmtpAuthenticate != 0 )
// {
// MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = Mail.nSmtpAuthenticate;
// }
#endregion
//已经约定的格式
MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/languagecode"] = 0x0804;
MailObj.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"] = "smtpServer";
#endregion
SmtpMail.Send(MailObj);
解决方案 »
- 有什么办法,可以在不申请新域名的前提下,让浏览器地址栏中的地址不带有IP地址
- 当updatepanel更新时,pageload执行吗?
- 如何用javascript给Label1赋值。
- 关于gridview的问题
- 我的dropdownlist的SelectedIndexChanged事件没有响应,为什么??哭啊???
- 在线等待有关网页中的数据库查询数据问题。
- 求个框架
- 急求asp高人!急急急!!!
- 那位大哥腿小弟几本好书啊?学asp.net的?
- asp.net中不安全的Sql语句
- 请问怎么用ASP.net在线发EMAIL,而且我的买的服务器好象不支持SMTP发邮件
- 遇到语法问题,在asp.net如何使用ADO?
{
MailMessage mail = new MailMessage();
mail.To = "[email protected]";
mail.From = "[email protected]";
mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); //set your password here SmtpMail.SmtpServer = "mail.mycompany.com"; //your real server goes here
SmtpMail.Send( mail );
}