Solved

sending email with

Posted on 2010-09-22
6
382 Views
Last Modified: 2012-05-10
Hi Experts,

I have incorporated this function that sends an email via System.Net.Mail.SmtpClient. It works fine on 5 of 6 computers, however it generates an error that complains about EHLO parameters, on the sixth. It feels like I have tried everything.

Any ideas? Se code.

Regards
Per

Dim pMailMessage As New MailMessage
        
With pMailMessage
  .From = New MailAddress(txtAnswerEmail.Text)

  'able to handle more then a single recipient 
  strAddresses = txtTo.Text.Replace(",", ";")
  For Each strX As String In strAddresses.Split(";"c)
    If strX.Trim.Length > 0 Then
      .To.Add(New MailAddress(strX))
    End If
  Next

  .Subject = txtSubject.Text
  .Body = "My company " & txtFrom.Text & " " & vbCrLf
  .Body &= "Org.nr " & txtOrgNr.Text & " " & vbCrLf
  .Body &= "Kontakt " & txtContact.Text & " " & vbCrLf
  .Body &= "E-post " & txtAnswerEmail.Text & " " & vbCrLf
  .Body &= "Adress " & txtAddress.Text & " " & vbCrLf
  .Body &= "Postnr " & txtZipCode.Text & " " & vbCrLf
  .Body &= "Ort " & txtCity.Text & " " & vbCrLf
  .Body &= "Telefon " & txtTelephone.Text & " " & vbCrLf
         
  .IsBodyHtml = False

End With
   
Dim objSMTPClient As New SmtpClient()
objSMTPClient.Host = "mail.mydomain.com" '
objSMTPClient.Port = 587
objSMTPClient.Credentials = New System.Net.NetworkCredential("order@mydomain.com", "pw")

objSMTPClient.Send(pMailMessage)

Open in new window

0
Comment
Question by:PerryDaynac
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:Chrissalter
ID: 33733283
Check the local firewall on the 6th machine

587 is a non standard port and probably wont be open

alternatively

add a try / catch around lines 28 - 34

use smtpexception instead of just exception and you will be able to catch the exact status code
 
0
 
LVL 7

Accepted Solution

by:
Chrissalter earned 500 total points
ID: 33733293
also look into the computername of that 6th machine

the ehlo command usually sends

EHLO <computername>

there may be something in the computername that is freaking the smtp server out
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 33733519
have you tried port 465?
have you tried to turn off your firewall for the test?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:PerryDaynac
ID: 33734243
Ok, great. It was the computer name, that was the problem.

However, I don't want our customers to manually change the computer name if the program fails.
Is there a way to allow special characters? (like to UTF-8)
In my case it was a special swedish character that made the error...


0
 
LVL 7

Expert Comment

by:Chrissalter
ID: 33734344
i do not believe you can change the ehlo command when using net.mail

its an outdated but standard feature

the only real alternative is to write the raw message and send it via telnet

its not as difficult as it seems as the commands are well documented
0
 

Author Closing Comment

by:PerryDaynac
ID: 33734537
Thank you!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 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