Link to home
Start Free TrialLog in
Avatar of khan_maswood
khan_maswood

asked on

Sending Email from VB.net using the same mailserver used for Lotus Notes

I am receiving the below mentioned error while sending the mail from my VB.net application.
The mailserver used is the same one used by our lotus notes.
Transaction failed. The server response was: Relay rejected for policy reasons.
Try

       
            Dim msg As MailMessage
            Dim objSmtpClient As New System.Net.Mail.SmtpClient()

            msg = New MailMessage()

            msg.From = New System.Net.Mail.MailAddress(txtFromId.Text)
            msg.To.Add(New System.Net.Mail.MailAddress(txtToId.Text))
            msg.Subject = "Test Mail"
            msg.Body = txtBody.Text
            objSmtpClient.UseDefaultCredentials = True
            objSmtpClient.Credentials = New Net.NetworkCredential("xxxxxxxx", "xxxxxxxx")
            objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network
            objSmtpClient.Host = txtIP.Text.Trim()
            objSmtpClient.Port = 25
            objSmtpClient.Send(msg)

        Catch ex As Exception

        End Try
Avatar of Yiogi
Yiogi

Your code is ok, the problem is with your exchange server policy. It will not let you relay and send mail as someone else from another machine.

You can configure exchange to allow relay but it's a security hole and I strongly advice against it.

If you do choose to configure it please make sure you only allowed a specific ip from the machine you want to send the email to be able to do this and don't open it for everyone on the internet or you will find out your mail server is getting abused and used for sending spam from all over the world.
ASKER CERTIFIED SOLUTION
Avatar of kris_per
kris_per

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial