I have to email sender class. 1 for the sending to external addresses using namespace System.Web.Mail and another for sending to internal address using namespace System.Net.Mail.
I would like to only use System.Net.Mail for both internal and external emials. The problem I ran into is "Mailbox Unavailable" when sending to external email addresses.
public EmailSender(string From, string To, string Bcc, string Subject, string Body)
{
this.m_strFrom = From;
this.m_strTo = To;
this.m_strBcc = Bcc;
this.m_strSubject = Subject;
this.m_strBody = Body;
this.m_strAttachment = Attachment;
/// instantiate MailMessage class
///
MailMessage mail = new MailMessage();
/// set addresses
///
mail.From = new MailAddress(m_strFrom);
mail.To.Add(m_strTo);
mail.Bcc.Add(m_strBcc);
/// set mail content
///
mail.Subject = m_strSubject;
mail.Body = m_strBody;
/// set mail body type to HTML
///
AlternateView htmlmail = AlternateView.CreateAlternateViewFromString(m_strBody, null, "text/html");
mail.AlternateViews.Add(htmlmail);
/// send mail to defined smtp server
///
SmtpClient smtp = new SmtpClient("heops-s01.heops.local");
smtp.Send(mail);
}
I would like to only use System.Net.Mail for both internal and external emials. The problem I ran into is "Mailbox Unavailable" when sending to external email addresses.
public EmailSender(string From, string To, string Bcc, string Subject, string Body)
{
this.m_strFrom = From;
this.m_strTo = To;
this.m_strBcc = Bcc;
this.m_strSubject = Subject;
this.m_strBody = Body;
this.m_strAttachment = Attachment;
/// instantiate MailMessage class
///
MailMessage mail = new MailMessage();
/// set addresses
///
mail.From = new MailAddress(m_strFrom);
mail.To.Add(m_strTo);
mail.Bcc.Add(m_strBcc);
/// set mail content
///
mail.Subject = m_strSubject;
mail.Body = m_strBody;
/// set mail body type to HTML
///
AlternateView htmlmail = AlternateView.CreateAlternateViewFromString(m_strBody, null, "text/html");
mail.AlternateViews.Add(htmlmail);
/// send mail to defined smtp server
///
SmtpClient smtp = new SmtpClient("heops-s01.heops.local");
smtp.Send(mail);
}