/// <summary>
/// 发送电子邮件
/// </summary>
/// <param name="toEmailAddress">邮件地址</param>
/// <param name="subTitle">邮件标题</param>
/// <param name="sBody">邮件内容</param>
/// <returns></returns>
public static bool SendEmail(string toEmailAddress, string subTitle, string sBody)
{
bool isSend = false;
if (!string.IsNullOrEmpty(toEmailAddress) && !string.IsNullOrEmpty(subTitle) && !string.IsNullOrEmpty(sBody))
{
Regex regEmail = new Regex(@"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
if (regEmail.IsMatch(toEmailAddress))
{
try
{
MailMessage m_message = new MailMessage();
m_message.BodyEncoding = System.Text.Encoding.UTF8;
m_message.To.Add(new MailAddress(toEmailAddress, subTitle));
m_message.Subject = subTitle;
m_message.IsBodyHtml = true;
m_message.Body = sBody;
SmtpClient m_smtpClient = new SmtpClient();
m_smtpClient.EnableSsl = true;
m_smtpClient.Send(m_message);
isSend = true;
}
catch
{
isSend = false;
}
}
}
return isSend;
}
这个是发送代码,但是我发送邮件的帐号和密码没有问题的,我有一个邮箱能收到的,请问是什么原因造成的啊
你看看他们又想里面的
SmtpClient m_smtpClient = new SmtpClient(); 都沒有設置其他屬性
这部分配置在config里面了