Solved

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

Posted on 2010-08-13
3
1,382 Views
Last Modified: 2013-11-30
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
0
Comment
Question by:khan_maswood
3 Comments
 
LVL 8

Expert Comment

by:Yiogi
ID: 33428676
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.
0
 
LVL 16

Accepted Solution

by:
kris_per earned 500 total points
ID: 33437125

Lotus Notes uses its own protocol to submit the mails to the Lotus Domino server...If you want to use the same method, then you have to use Notes com objects in .net; check out this link => http://www.codeproject.com/KB/cs/LotusNotesWithCS.aspx

If you want to use System.Net.Mail.SmtpClient as above in your code...SMTP must have been enabled in Lotus Domino server (check with your admin). In this case I think you have to use the smtp server address in SmtpClient constructor like:
Dim objSmtpClient As New System.Net.Mail.SmtpClient("server address")
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now