Link to home
Start Free TrialLog in
Avatar of PerryDaynac
PerryDaynacFlag for Sweden

asked on

sending email with

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

Avatar of Chrissalter
Chrissalter
Flag of United Kingdom of Great Britain and Northern Ireland image

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
 
ASKER CERTIFIED SOLUTION
Avatar of Chrissalter
Chrissalter
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Avatar of Éric Moreau
have you tried port 465?
have you tried to turn off your firewall for the test?
Avatar of PerryDaynac

ASKER

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...


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
Thank you!