Solved

sending email with

Posted on 2010-09-22
6
380 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 69

Expert Comment

by:Éric Moreau
ID: 33733519
have you tried port 465?
have you tried to turn off your firewall for the test?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

23 Experts available now in Live!

Get 1:1 Help Now