unable to relay with vb.net system.mail

  • Thread starter Thread starter Chris Thunell
  • Start date Start date
C

Chris Thunell

I am using the following code to send email out in a vb.net web program
through an exchange 2003 server. My web server is on a separate server.
When i try to send email inside the office, it works fine... but when i try
to send email outside the company i get "unable to relay" error message.
Please look at the code, i don't see a way to send username and password
credentials to allow the relaying to occur (I don't want unauthenticated
relaying to be allowed, because that would open our system up for outsiders
to relay as well). Both the web server and exchange are within our
organzation. Any thoughts?
Thanks in advance!
Chris Thunell
(e-mail address removed)
Imports System.Web

Imports System.Web.Mail


Dim message As New MailMessage

Dim Attachment As System.Web.Mail.MailAttachment

With message

..BodyFormat = MailFormat.Html

..To = "(e-mail address removed)" 'RecipientList

..Cc = MessageFrom

..Subject = MessageSubject

..From = MessageFrom

..Body = MessageBody

If Len(Trim(AttachmentLocation)) > 1 Then

Attachment = New MailAttachment(Trim(AttachmentLocation))

..Attachments.Add(Attachment)

End If

End With

SmtpMail.SmtpServer = "myemailserver.domain.com"

SmtpMail.Send(message)
 
There doesn't look to be anything wrong with your code, so your mail admin
should be able to set a rule in your mail server to allow relays from the
web servers IP address without compromising the ability to stop relays from
outside the company

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
Do you have a Microsoft article that tells me how to do that?
Chris Thunell
(e-mail address removed)
 
Back
Top