Link to home
Start Free TrialLog in
Avatar of elmcomputers
elmcomputers

asked on

Problem sending Email from VB.NET application

Hello,

This is a problem with a simple DOT NET 2 application which sends email using system.net.mail.  The email has a small PDF attachment.

It works fine here at my office on my notebook with a nuber of SMTP servers and two different ISP's.

However at the client's site (I change the SMTP server/port to the one they need to use), the email function hangs the application with no error trapped.    In the meantime while I am waiting I cannot end the process even if I use task manager.  i have to restart the computer.

I can ping the mail server and get the three expected replies.

At a command prompt I can use telnet to send an email.

I am not sure where to begin to diagnose the problem.   It is on a large corporate network and I cannot hook my notebook into it and they are locked down so I cannot install another email client to test.    

I have tried lowering the timeout value on the smtpclient and it made no difference.

Any Ideas?

Thanks,

Stephen Simpson
Imports system.net.mail
 
Try
         Dim eMail As New MailMessage
         With eMail
 
              .From = New System.Net.Mail.MailAddress(sEmailReplyTo)
 
              Dim recipient As System.Net.Mail.MailAddress = New System.Net.Mail.MailAddress(Trim(sEmail))
              .To.Add(recipient)
 
              .Subject = "Report for " & sLocation
              .Body = _
              "Attention: " & sContact & vbCrLf & _
              "Subject: Test " & vbCrLf & _
              "Location: " & sLocation & vbCrLf & _
              "Call Date: " & sCallDate & vbCrLf & vbCrLf & _
              sTextOfEmail
 
              .Attachments.Add(New Net.Mail.Attachment(di.FullName & "\" & Trim(sAttach)))
 
               .IsBodyHtml = False
          End With
 
         Dim smtpclient As New System.Net.Mail.SmtpClient
         smtpclient.Host = sSMTPServer 
         smtpclient.Port = sSMTPPort '1025
 
         If sSMTPUser <> "" Then
                smtpclient.Credentials = New System.Net.NetworkCredential(sSMTPUser, sSMTPPassword)  
         End If
 
         smtpclient.Send(eMail)
 
         eMail.Dispose()
 
Catch exEmail As Exception                    
           DisplayStatus("Email processing failed while processing:" & vbCrLf & sTrans & vbCrLf & exEmail.Message, True)
End Try 
Open in New Window Select All Tags: 
EMAIL, VB.NET.SMTP

Open in new window

Avatar of mastoo
mastoo
Flag of United States of America image

It could be client antivirus software blocking programs from sending email - maybe try it with antivirus momentarily disabled.  Another thought would be check the windows event logs in case there's some security failure being logged, or maybe trouble resolving the smtp server.
Avatar of elmcomputers
elmcomputers

ASKER

THanks for you comment.  I will work on this.  The problem is that this is on a large corporate LAN and i have limited access to settings and the control panel.  I do not expect that I will be able to disable the anti virus for a test
ASKER CERTIFIED SOLUTION
Avatar of AxleWack
AxleWack

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
I called up the tech support department of the company that owned the network and described the problem that I was having.

A couple of days later the software, without modification just started to work properly.  I assume that the support team had some setting wrong, but I guess I will never know what it was

Thanks
I had the same issue a while ago... I believe it was something to do with their settings allowing mails to go out or to do with their SMTP setting on their server from where emails are being sent from.

Glad its working atleast