G
Guest
Greetings all,
I'm trying to send an e-mail from a Windows application thru MS Exchange
Server 2007 that is in my LAN. The setup for Exchange server is very basic,
it's running on Server 2003 R2 x64 machine. Here is the code I'm trying to
use to send the email:
Public Sub SendMail()
Dim strTo As String = frmMain.txtTo.Text
Dim strFrom As String = frmMain.txtFrom.Text
Dim strSubject As String = frmMain.txtSubject.Text
Dim strBody As String = frmMain.txtBody.Text
Dim mailMessage As New System.Net.Mail.MailMessage(strFrom, strTo,
strSubject, strBody)
Dim mailClient As New
System.Net.Mail.SmtpClient("IpAddressOfComputerRunningExchangeServer", 25)
Dim mailCredentials As New
System.Net.NetworkCredential("MyDomain.com\MyUserName",
"ExchangeUserPassword", "MyDomain.com")
mailClient.UseDefaultCredentials = False
mailClient.Credentials = mailCredentials
mailClient.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
'mailClient.EnableSsl = True
Try
'mailClient.ClientCertificates.Add
((System.Security.Cryptography.X509Certificates.X509Certificate2.CreateFromSignedFile("C:\My Certificate in DER format.cer")))
mailClient.Send(mailMessage)
Catch ex As Exception
frmMain.txtInfo.Text = ex.ToString
Exit Sub
End Try
frmMain.txtInfo.Text = "Your message was sucessfully sent."
End Sub
Notice I have two lines of code commented out. If I run the the app and try
to send the email with these lines commented out I get the following
exception "The server response was 5.7.1 Unable to relay."
If I run the app with those lines not commented out, I receive the following
exception "The remote certificate is invalid according to the validation
procedure."
I need help debugging this application. I can usually get by with just the
exception but I am at my wits end here. I've read some threads about
enabling tracing thru the use of an app.config file in my project, but I'm
struggling with that as well. Any help you could provide would be much
appreciated. Please let me know if you need any additional details. Thank
you.
I'm trying to send an e-mail from a Windows application thru MS Exchange
Server 2007 that is in my LAN. The setup for Exchange server is very basic,
it's running on Server 2003 R2 x64 machine. Here is the code I'm trying to
use to send the email:
Public Sub SendMail()
Dim strTo As String = frmMain.txtTo.Text
Dim strFrom As String = frmMain.txtFrom.Text
Dim strSubject As String = frmMain.txtSubject.Text
Dim strBody As String = frmMain.txtBody.Text
Dim mailMessage As New System.Net.Mail.MailMessage(strFrom, strTo,
strSubject, strBody)
Dim mailClient As New
System.Net.Mail.SmtpClient("IpAddressOfComputerRunningExchangeServer", 25)
Dim mailCredentials As New
System.Net.NetworkCredential("MyDomain.com\MyUserName",
"ExchangeUserPassword", "MyDomain.com")
mailClient.UseDefaultCredentials = False
mailClient.Credentials = mailCredentials
mailClient.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
'mailClient.EnableSsl = True
Try
'mailClient.ClientCertificates.Add
((System.Security.Cryptography.X509Certificates.X509Certificate2.CreateFromSignedFile("C:\My Certificate in DER format.cer")))
mailClient.Send(mailMessage)
Catch ex As Exception
frmMain.txtInfo.Text = ex.ToString
Exit Sub
End Try
frmMain.txtInfo.Text = "Your message was sucessfully sent."
End Sub
Notice I have two lines of code commented out. If I run the the app and try
to send the email with these lines commented out I get the following
exception "The server response was 5.7.1 Unable to relay."
If I run the app with those lines not commented out, I receive the following
exception "The remote certificate is invalid according to the validation
procedure."
I need help debugging this application. I can usually get by with just the
exception but I am at my wits end here. I've read some threads about
enabling tracing thru the use of an app.config file in my project, but I'm
struggling with that as well. Any help you could provide would be much
appreciated. Please let me know if you need any additional details. Thank
you.