asp.net中发送邮件的几种方式
2004-11-22 14:52
661 查看
private void BnOk_Click(object sender, System.EventArgs e)
{
string strTo=txtEmail.Text;
string strFrom="username@domain.com";
string strSubject="您的朋友推荐一份职位给您";
string strBody = "<b>test</b>";
MailMessage Message = new MailMessage();
// SmtpMail.SmtpServer="?.?.?.?";
// Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
//
// Message.Fields.Add(http://schemas.microsoft.com/cdo/configuration/sendusername",username"); //set your username here
//
// Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password"); //set your password here
SmtpMail.SmtpServer="?.?.?.?";
Message.To = strTo;
Message.From = strFrom;
Message.Subject = strSubject;
Message.Body = strBody;
SmtpMail.Send(Message);
//JMail
// jmail.SpeedMailerClass Message=new jmail.SpeedMailerClass();
// Message.SendMail(strFrom,strTo,strSubject,strBody,"");
//CDONTS
// CDONTS.NewMailClass n=new CDONTS.NewMailClass();
// n.BodyFormat=0;
// n.MailFormat=0;
// n.Send(strFrom,strTo,strSubject,strBody,1);
/*
CDONTS组件文字格式:
BodyFormat=0 html方式
BodyFormat=1 纯文本方式
*/
//CDOSYS
// CDO.MessageClass m=new CDO.MessageClass();
// m.To=strTo;
// m.From=strFrom;
// m.Subject=strSubject;
// m.TextBody=strBody;
// m.Send();
bnOk.Text="发送成功";
bnOk.Enabled=false;
}
{
string strTo=txtEmail.Text;
string strFrom="username@domain.com";
string strSubject="您的朋友推荐一份职位给您";
string strBody = "<b>test</b>";
MailMessage Message = new MailMessage();
// SmtpMail.SmtpServer="?.?.?.?";
// Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
//
// Message.Fields.Add(http://schemas.microsoft.com/cdo/configuration/sendusername",username"); //set your username here
//
// Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password"); //set your password here
SmtpMail.SmtpServer="?.?.?.?";
Message.To = strTo;
Message.From = strFrom;
Message.Subject = strSubject;
Message.Body = strBody;
SmtpMail.Send(Message);
//JMail
// jmail.SpeedMailerClass Message=new jmail.SpeedMailerClass();
// Message.SendMail(strFrom,strTo,strSubject,strBody,"");
//CDONTS
// CDONTS.NewMailClass n=new CDONTS.NewMailClass();
// n.BodyFormat=0;
// n.MailFormat=0;
// n.Send(strFrom,strTo,strSubject,strBody,1);
/*
CDONTS组件文字格式:
BodyFormat=0 html方式
BodyFormat=1 纯文本方式
*/
//CDOSYS
// CDO.MessageClass m=new CDO.MessageClass();
// m.To=strTo;
// m.From=strFrom;
// m.Subject=strSubject;
// m.TextBody=strBody;
// m.Send();
bnOk.Text="发送成功";
bnOk.Enabled=false;
}
相关文章推荐
- ASP.NET控件的设计时支持
- ASP.NET 中 Cookie 的基本知识
- 使用 ASP.NET 的验证控件(转)
- 在 ASP.NET 中使用计时器(Timer)
- Windows 2003下不注册组件用ASP发邮件
- 新的学期开始了。。。
- “Visual Studio.net已检测到指定的Web服务器运行的不是Asp.net1.1版。您将无法运行Asp.net Web应用程序或服务”问题的解决方法
- 常用ASP.NET解决问题
- 摘抄-我学习ASP.NET时的笔记
- 使用 ASP.NET 顯示事件日誌紀錄
- 在asp.net里创建CrystalReportViewer时老是出错,后来在这里查了些资料才搞定要在web.config中设置如下
- ASP.NET发邮件(20041120)
- 维护 ASP 应用程序的安全
- 发布攻击台湾国旗设计网的ASP代码:
- 创建ASP.NET WEB自定义控件——例程2
- 创建ASP.NET WEB自定义控件——例程1
- 如何解决ASP.NET中中文不能正常显示问题?
- [ASP.NET]一个实用的弹出窗口函数
- 基于ASP.NET的自定义分页显示
- 如何把ASP编写成DLL