Solved

Problem sending Email from VB.NET application

Posted on 2009-04-07
2
293 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 69

Accepted Solution

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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

744 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

9 Experts available now in Live!

Get 1:1 Help Now