Solved

sending email with

Posted on 2010-09-22
6
383 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
Independent Software Vendors: 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!

 

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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
Get sourcecode path 14 65
Create a Dropdown list with sub group 10 43
Import a excel sheet in a grid 2 45
.NET Redemption/Outlook Examples 3 35
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 …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

752 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