Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mailbox unavailable when sending to an external address

Status
Not open for further replies.

SCantoria

Programmer
Sep 23, 2005
100
US
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);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top