绝对正确!!!!!!!

街角嘚堕落 2011-04-02 11:17:11
string s = "";
Boolean b = true;
string from_mail = ConfigurationManager.AppSettings.GetValues("mail_from")[0];
string user = ConfigurationManager.AppSettings.GetValues("mail_user")[0];
string pass = ConfigurationManager.AppSettings.GetValues("mail_pass")[0];

MailMessage mail = new MailMessage();

//发件人地址
mail.From = from_mail;

//收件人地址

mail.To = mailTo;

//邮件主题
mail.Subject = mailSubject;

//邮件内容
mail.Body = mailContent;

//优先级
int p = mailPriority;
switch (p)
{
case 0:
mail.Priority = MailPriority.High;
break;
case 1:
mail.Priority = MailPriority.Low;
break;
default:
mail.Priority = MailPriority.Normal;
break;
}

//设置邮件格式
int f = 1;
if (f == 0)
mail.BodyFormat = MailFormat.Text;
else
mail.BodyFormat = MailFormat.Html;

//设置服务器

//发送邮件
//设置服务器验证
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//验证用户名
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", user);
//验证密码
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", pass);

try
{
SmtpMail.SmtpServer = ConfigurationManager.AppSettings.GetValues("mail_server")[0];
SmtpMail.Send(mail);
s = "good";
}
catch(Exception ex)
{
b = false;
s = ex.Message.ToString();
}

return s;
...全文
132 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
接分来的
lennydou 2011-05-06
  • 打赏
  • 举报
回复
散分吗
isjoe 2011-05-06
  • 打赏
  • 举报
回复
有谁说你的代码不对吗?来这里验证?
jin225 2011-05-06
  • 打赏
  • 举报
回复
呵呵
回复内容太短了!
guojun009 2011-04-22
  • 打赏
  • 举报
回复
这个不解释。
zhu6100441 2011-04-21
  • 打赏
  • 举报
回复
对,太对了,没人能说不对。
  • 打赏
  • 举报
回复
对,太对了
changjiangzhibin 2011-04-08
  • 打赏
  • 举报
回复
有人说它不正确了 ?

源码,工具 网上都有现成的
小童 2011-04-07
  • 打赏
  • 举报
回复
你是散分的?
woanon 2011-04-07
  • 打赏
  • 举报
回复
散分的嗎?
sgchen 2011-04-07
  • 打赏
  • 举报
回复
解分来了
number 2011-04-02
  • 打赏
  • 举报
回复
你的问题是? 或者说,你是散分的? 再表达一下吧,一段代码看得晕。

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧