没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
vs2003和vs2005两种不同的发送email方式
vs2003
public static bool SendMail(string from, string to, string subject, string body, string smtpServer, string userName, string password, ref string result)
{
MailMessage mailMsg = new MailMessage();
//设置正文格式
mailMsg.BodyFormat = MailFormat.Html;
//设置收件人的邮件地址
mailMsg.To = to;
//设置发送者的邮件地址
mailMsg.From = from;
//设置邮件主题
mailMsg.Subject = subject;
//设置邮件内容
mailMsg.Body = body;
//设置支持服务器验证
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//设置用户名
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", userName);
//设置用户密码
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
try
{
//设置发送邮件服务器
SmtpMail.SmtpServer = smtpServer;
//发送邮件
SmtpMail.Send(mailMsg);
return true;
vs2003
public static bool SendMail(string from, string to, string subject, string body, string smtpServer, string userName, string password, ref string result)
{
MailMessage mailMsg = new MailMessage();
//设置正文格式
mailMsg.BodyFormat = MailFormat.Html;
//设置收件人的邮件地址
mailMsg.To = to;
//设置发送者的邮件地址
mailMsg.From = from;
//设置邮件主题
mailMsg.Subject = subject;
//设置邮件内容
mailMsg.Body = body;
//设置支持服务器验证
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//设置用户名
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", userName);
//设置用户密码
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
try
{
//设置发送邮件服务器
SmtpMail.SmtpServer = smtpServer;
//发送邮件
SmtpMail.Send(mailMsg);
return true;
资源评论
- jackbaby2014-07-22代码完全可用,赞!!!
a7339852
- 粉丝: 0
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功