You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

87 lines
3.2 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Stone.Common;
namespace Stone.WinBiz.JISAdmin
{
public class F_Mail
{
public static void Send(string msg)
{
try
{
string To = MyAppconfig.ReadValue("Email").Trim(); if (To == "") return;
string From = MyAppconfig.ReadValue("MailSender");
string Server = MyAppconfig.ReadValue("MailServer");
string MailUserName = MyAppconfig.ReadValue("MailUserName");
string Password = MyAppconfig.ReadValue("MailPassword");
int Port = Convert.ToInt32(MyAppconfig.ReadValue("MailPort"));
string MailTitle = "JIS5000邮件提醒";
string MailBody = msg + "<br><br>时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
MySmtpMail SmtpMail = new MySmtpMail(To, From, MailBody, MailTitle, Server, MailUserName, Password, false, Port, false, "");
SmtpMail.Send();
}
catch (Exception ex)
{
MyLogger.Write("发邮件失败,原因为:" + ex.Message);
}
}
public static void Send(string title, string msg)
{
try
{
string To = MyAppconfig.ReadValue("Email").Trim(); if (To == "") return;
string From = MyAppconfig.ReadValue("MailSender");
string Server = MyAppconfig.ReadValue("MailServer");
string MailUserName = MyAppconfig.ReadValue("MailUserName");
string Password = MyAppconfig.ReadValue("MailPassword");
int Port = Convert.ToInt32(MyAppconfig.ReadValue("MailPort"));
string MailTitle = title;
string MailBody = msg + "<br><br>时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
MySmtpMail SmtpMail = new MySmtpMail(To, From, MailBody, MailTitle, Server, MailUserName, Password, false, Port, false, "");
SmtpMail.Send();
}
catch (Exception ex)
{
MyLogger.Write("发邮件失败,原因为:" + ex.Message);
}
}
public static void Send(string title, string msg,string to)
{
try
{
string To = to; if (To == "") return;
string From = MyAppconfig.ReadValue("MailSender");
string Server = MyAppconfig.ReadValue("MailServer");
string MailUserName = MyAppconfig.ReadValue("MailUserName");
string Password = MyAppconfig.ReadValue("MailPassword");
int Port = Convert.ToInt32(MyAppconfig.ReadValue("MailPort"));
string MailTitle = title;
string MailBody = msg + "<br><br>时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
MySmtpMail SmtpMail = new MySmtpMail(To, From, MailBody, MailTitle, Server, MailUserName, Password, false, Port, false, "");
SmtpMail.Send();
}
catch (Exception ex)
{
MyLogger.Write("发邮件失败,原因为:" + ex.Message);
}
}
}
}