用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - c#代码库

发送邮件, 根据学院邮箱

2015-05-18 作者: 曏小強2举报

[c#]代码库

public static string SendMail(string to, string toname, string body, int vbid)
       {
           string responseMsg = string.Empty;
           try
           {
               DataTable dtBasic = new DataTable();
 
               DBHelper.fnInsert.Read_VoteBasic(vbid, out dtBasic);
               string mSubject = "请注意查看投票信息";
 
               MailMessage m = new MailMessage();
               m.From = new MailAddress("201103haozheng@edu2act.org", "投票通知");
               m.To.Add(new MailAddress(to, toname));
               if (dtBasic != null && dtBasic.Rows.Count.Equals(1))
               {
                   mSubject = "关于 “" + dtBasic.Rows[0]["VTitle"] + "” 的投票信息";
                   body = "\r\n \r\n 信息简介:\r\n " + dtBasic.Rows[0]["VContent"] + "\r\n \r\n 截止日期:" + ((DateTime)dtBasic.Rows[0]["VDeadline"]).ToString("yyyy-MM-dd hh:mm") + " \r\n \r\n " + body;
               }
               m.Subject = mSubject;
               m.Body = body;
 
               SmtpClient client = new SmtpClient("email.edu2act.org");
               client.Send(m);
               responseMsg = "success";
           }
           catch (Exception ex)
           {
               responseMsg = "faild-" + ex.Message + ex.StackTrace;
               //throw;
           }
           return responseMsg;
       }


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...