SmtpMail Error
-
I am having a problem sending email using
System.Web.Mail
. I have provided detailed information about the issue below. Any help or comments would be greatly appreciated. ---------------------- NETWORK SETUP: ---------------------- - Web Server - A server running windows 2000 and IIS5. - Email Server - A seperate server running windows 2000 and Exchange 2000. --------------------- ERROR C# CODE: --------------------- Comments: If I entersomeone@mycompanydomain.com
for thetestMessage.To
property everything works great. I have also tried putting in the actual ip address of EXCHSRVR, but it did not change anything.MailMessage testMessage = new MailMessage(); testMessage.To = "me@anotherdomain.com"; testMessage.From = "me@mycompanydomain.com"; testMessage.Subject = "Test Email"; testMessage.Body = "Am I working???"; SmtpMail.SmtpServer = "EXCHSRVR"; SmtpMail.Send(invoiceMessage);
----------------------------- EXCEPTIONS THROWN: ----------------------------- Comments: I find it very strange that the
System.Runtime.InteropServices.COMException
says, "Unable to relay forme@anotherdomain.com
." I would think it should say "Unable to relay forme@mycompanydomain.com
." Main exception.**System.Web.HttpException**
Message: Could not access 'CDO.Message' object. Error Code: -2147467259 First inner exception.**System.Reflection.TargetInvocationException**
Message: Exception has been thrown by the target of an invocation. Second inner exception.**System.Runtime.InteropServices.COMException**
Message: The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for me@anotherdomain.com --------------------------------------------------------- INTERNET HEADER FOR A SUCCESSFUL SEND: --------------------------------------------------------- Microsoft Mail Internet Headers Version 2.0 Received: from NS ([64.243.150.162]) by exchange.mycompanydomain.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 30 Sep 2003 10:25:20 -0500 From: me@mycompanydomain.com To: someone@mycompanydomain.com Subject: Test Email Date: Tue, 30 Sep 2003 10:25:20 -0500 Message-ID: 000101c38767$0f291e00$b80103c0@mycompanydomain.com MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: -
I am having a problem sending email using
System.Web.Mail
. I have provided detailed information about the issue below. Any help or comments would be greatly appreciated. ---------------------- NETWORK SETUP: ---------------------- - Web Server - A server running windows 2000 and IIS5. - Email Server - A seperate server running windows 2000 and Exchange 2000. --------------------- ERROR C# CODE: --------------------- Comments: If I entersomeone@mycompanydomain.com
for thetestMessage.To
property everything works great. I have also tried putting in the actual ip address of EXCHSRVR, but it did not change anything.MailMessage testMessage = new MailMessage(); testMessage.To = "me@anotherdomain.com"; testMessage.From = "me@mycompanydomain.com"; testMessage.Subject = "Test Email"; testMessage.Body = "Am I working???"; SmtpMail.SmtpServer = "EXCHSRVR"; SmtpMail.Send(invoiceMessage);
----------------------------- EXCEPTIONS THROWN: ----------------------------- Comments: I find it very strange that the
System.Runtime.InteropServices.COMException
says, "Unable to relay forme@anotherdomain.com
." I would think it should say "Unable to relay forme@mycompanydomain.com
." Main exception.**System.Web.HttpException**
Message: Could not access 'CDO.Message' object. Error Code: -2147467259 First inner exception.**System.Reflection.TargetInvocationException**
Message: Exception has been thrown by the target of an invocation. Second inner exception.**System.Runtime.InteropServices.COMException**
Message: The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for me@anotherdomain.com --------------------------------------------------------- INTERNET HEADER FOR A SUCCESSFUL SEND: --------------------------------------------------------- Microsoft Mail Internet Headers Version 2.0 Received: from NS ([64.243.150.162]) by exchange.mycompanydomain.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 30 Sep 2003 10:25:20 -0500 From: me@mycompanydomain.com To: someone@mycompanydomain.com Subject: Test Email Date: Tue, 30 Sep 2003 10:25:20 -0500 Message-ID: 000101c38767$0f291e00$b80103c0@mycompanydomain.com MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer:Problem solved. The webserver had to be setup in Exchange to be allowed to send emails out. Mark Sanders