Solved

sending email with

Posted on 2010-09-22
6
384 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

617 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