Avatar of tmaususer
tmaususer
Flag for United States of America asked on

VB.Net Email Issue

Hello experts. I am having an issue with a very simple request form (vb.net) regarding sending an email once the submit button is pressed. My email server is exchange 2010. Here is the issue. Internally in my building the form works great. If I am working remotely I connect to my network using cisco vpn client. My issue is when connected via the cisco vpn client when I attempt to submit the form I get an error email not sent. I thought maybe it had something to do with my exchange server name so I placed my server IP address as well and still the same issue. My code is below if needed. So the question is why does this work internally but not remotely via vpn?

Public Function fnMailer(ByVal strPassEmailTo As String) As Boolean

        Dim strError As String = ""
        Dim MailMsg As MailMessage = New MailMessage

        MailMsg.Subject = "Service Request"
        MailMsg.Body = "Generated by system - Please do not reply to message" & vbCrLf & vbCrLf

        MailMsg.From = New MailAddress("test@test.com")

        MailMsg.To.Add(strPassEmailTo)

        MailMsg.Body += Global_mailMessage
        Dim mailClient As New System.Net.Mail.SmtpClient("servername")

        mailClient.UseDefaultCredentials = True

        Try
            mailClient.Send(MailMsg)
        Catch ex As SmtpException
            MessageBox.Show("Error sending email")
            Return False
        End Try

        Return True

    End Function
Visual Basic.NET.NET ProgrammingExchange

Avatar of undefined
Last Comment
tmaususer

8/22/2022 - Mon
Éric Moreau

what does ex.Message contains in your Catch?
Éric Moreau

you might also check if http://systemnetmail.com/ has troubleshooting for you
tmaususer

ASKER
All the try catch says is Error sending email. That's what gets displayed.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Éric Moreau

this is because you force it using this:
MessageBox.Show("Error sending email")

Open in new window


Try:
MessageBox.Show(ex.Message)

Open in new window

tmaususer

ASKER
Got it. I will change my code and test it to see what error I receive and report back. Thanks.
tmaususer

ASKER
Here is the error
error.JPG
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Éric Moreau

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
tmaususer

ASKER
Thanks,

Checking it out now.