Exemplo n.º 1
0
 public ArgsHelp SaveEmailInfo(yjgl_yjmx yjmx)
 {
     ArgsHelp ah = new ArgsHelp();
     try
     {
         yjmxDB.yjgl_yjmx.InsertOnSubmit(yjmx);
         yjmxDB.SubmitChanges();
     }
     catch (Exception e)
     {
         ah.flag = false;
         ah.msg = e.Message;
     }
     return ah;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="senderName"></param>
 /// <param name="receiver"></param>
 /// <param name="topic"></param>
 /// <param name="content"></param>
 /// <param name="psw"></param>
 /// <returns></returns>
 public ArgsHelp SendMail(string sender, string senderName, string receiver, string topic, string content, string psw,int userID)
 {
     ArgsHelp ah = new ArgsHelp();
     try
     {
         GlobalVar.message.From = new MailAddress(sender, senderName);//必须是提供smtp服务的邮件服务器
         GlobalVar.message.To.Clear();//清空以前的收件人
         GlobalVar.message.To.Add(new MailAddress(receiver));  //收件人
         GlobalVar.message.Subject = topic;
         GlobalVar.message.IsBodyHtml = true;
         GlobalVar.message.BodyEncoding = System.Text.Encoding.UTF8;
         GlobalVar.message.Body = content;
         GlobalVar.message.Priority = System.Net.Mail.MailPriority.High;
         SmtpClient client = new SmtpClient("mail.skywalk.cn", 25); // 587;//Gmail使用的端口
         client.Credentials = new System.Net.NetworkCredential(sender, psw); //这里是申请的邮箱和密码
         client.EnableSsl = false; //必须经过ssl加密
         string fj = string.Empty;
         client.Send(GlobalVar.message);
         foreach (var id in GlobalVar.AttachmentID)
         {
             fj += id + "|";
         }
         yjgl_yjmx yjmx = new yjgl_yjmx
         {
             user_id = userID,
             yj_fssj = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
             yj_nr = content,
             yj_zt = topic,
             yj_sjr = receiver,
             yj_fj = fj
         };
         emailglDAO.SaveEmailInfo(yjmx);
     }
     catch (Exception e)
     {
         ah.flag = false;
         ah.msg = e.Message;
     }
     return ah;
 }
 partial void Deleteyjgl_yjmx(yjgl_yjmx instance);
 partial void Updateyjgl_yjmx(yjgl_yjmx instance);
 partial void Insertyjgl_yjmx(yjgl_yjmx instance);