Sending mails on Exchange 2007

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello:

I have an Exchange 2007 working fine, and it’s possible to send and receive
mails from mail clients to external domains.

I try to send a mail from my application using this server. Te code is like
this:

MailAddress From = new MailAddress("(e-mail address removed)", "Automated
Sender");
MailAddress To = new MailAddress("(e-mail address removed)");
MailMessage myMail = new MailMessage(From, To);
myMail.IsBodyHtml = true;
myMail.Subject = "Automated mail";
myMail.Body = "Test mail...";
myMail.Sender = From;
SmtpClient smtp = new SmtpClient("mailserver.mydomain.com");
smtp.UseDefaultCredentials = false;
smtp.Credentials=new System.Net.NetworkCredential("username","password");
smtp.Send(myMail);

It works if the destination domain is an internal domain, but with and
external domain it launch an "Unable to relay" exception:

"El buzón de correo no está disponible. La respuesta del servidor fue:
5.7.1 Unable to relay"

English, aprox. translate:

"Mailbox unavailable. Response from server: 5.7.1 Unable to relay"

If I try to send a mail from Outlook with the authentication option active
IT WORKS!

This source code works with Exchange 2003.

Some ideas?
Thank's and sorry for my bad English!
 
Back
Top