利用System.Net.Mail发送邮件老是失败,代码和配置全在里面。救命啊
public Email(string p_strAccepter,string p_strBcc,string p_strCc,string p_strSender,
string p_strBody,string p_strSubject,string p_strFile,bool p_blIsBodyHtml)
{
m_strAccepter = p_strAccepter.Trim();
m_strBody = p_strBody.Trim();
m_strBcc= p_strBcc.Trim();
m_strCc = p_strCc.Trim();
m_strFile = p_strFile.Trim();
m_strSender = p_strSender.Trim();
m_strSubject = p_strSubject.Trim();
m_mmMail = new MailMessage(m_strSender, m_strAccepter);
m_mmMail.Body = m_strBody;
m_mmMail.Subject = m_strSubject;
if (!string.IsNullOrEmpty(m_strCc))
{
m_mmMail.CC.Add(m_strCc);
}
if (!string.IsNullOrEmpty(m_strBcc))
{
m_mmMail.Bcc.Add(m_strBcc);
}
m_mmMail.IsBodyHtml = p_blIsBodyHtml ? true : false;
if (!string.IsNullOrEmpty(m_strFile))
{
Attachment attchment = new Attachment(m_strFile);
m_mmMail.Attachments.Add(attchment);
}
}
/// <summary>
/// 实现发送电子邮件的功能,false失败;true成功
/// </summary>
/// <returns> false失败;true成功 </returns>
public bool SendEmail()
{
SmtpClient sc = new SmtpClient();
sc.Host = "localhost ";
sc.Port = 25;