Solved

sending email with

Posted on 2010-09-22
6
379 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
Comment Utility
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
Comment Utility
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
Comment Utility
have you tried port 465?
have you tried to turn off your firewall for the test?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:PerryDaynac
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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 …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

12 Experts available now in Live!

Get 1:1 Help Now