Solved

Problem sending Email from VB.NET application

Posted on 2009-04-07
2
311 Views
Last Modified: 2013-11-30
Hello,

This is a problem with a simple DOT NET 2 application which sends emai using system.net.mail.

It works fine here at the office on my notebook with a nuber of SMTP servers.

However at the client's site (I change the SMTP server/port to the one they need to use), the email function hangs and after a long time (Several minutes) gives a timeout error message.  In the meantime while I am waiting I cannot end the process even if I used task manager.

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

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.

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 = "WTS for " & sLocation
              .Body = _
              "Attention: " & sContact & vbCrLf & _
              "Subject: # Edited by ModernMatt #" & 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

0
Comment
Question by:elmcomputers
2 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 24091435
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with adding DLL file in Windows project 20 47
VB.net Excel VSTO Add-in version compatability 2 17
"lblTime is not declared" 3 34
Web page design problem 3 16
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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