#region 发送邮箱方法
/// <summary>
/// 发送邮箱方法
/// </summary>
/// <param>发送到的邮箱地址</param>
/// <param>姓名</param>
/// <returns>发送成功 返回 true 否则返回 false</returns>
public bool GetEmail(string useremail, string username)
{
DateTime dt = DateTime.Now;
string gettime = dt.ToLongDateString().ToString();
string _MailAddress = "邮箱地址";
string _MailNickName = "xxx";
string _MailPassword = "邮箱密码";
string _MailSmtpHost = "smtp.163.com";
string _MailSmtpPort = "25";
string _To = useremail;
string _Title = "xxxxxx";
string _Body = "亲爱的“" + username + "”用户:<br><br>您好!";
string strXmlFile = HttpContext.Current.Server.MapPath("/config/mail.config");
XmlControl XmlTool = new XmlControl(strXmlFile);
XmlTool.Update("Root/Address", _MailAddress);
XmlTool.Update("Root/NickName", _MailNickName);
XmlTool.Update("Root/Password", _MailPassword);
XmlTool.Update("Root/SmtpHost", _MailSmtpHost);
XmlTool.Update("Root/SmtpPort", _MailSmtpPort);
XmlTool.Update("Root/ToAddress", useremail);
XmlTool.Update("Root/UserInfo", username);
XmlTool.Save();
XmlTool.Dispose();
if (GmailHelp.GmailSendMail(username, _To, _Body, _Title, _MailAddress, _MailNickName, _MailPassword, _MailSmtpHost, int.Parse(_MailSmtpPort)))
{
return true;
}
else
{
return false;
}
}
#endregion
#region 获取主机名称
/// <summary>
/// 获取主机名称 返回如 or :8080 注意没有
/// </summary>
/// <returns></returns>
public static string GetHttpHost()
{
int Port = HttpContext.Current.Request.Url.Port;
if (Port == 80)
{
return HttpContext.Current.Request.Url.Host;
}
else
{
return HttpContext.Current.Request.Url.Host + ":" + Port;
}
}
#endregion