PerryDaynac
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
I have incorporated this function that sends an email via System.Net.Mail.SmtpClient
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)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
have you tried port 465?
have you tried to turn off your firewall for the test?
have you tried to turn off your firewall for the test?
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...
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
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
ASKER
Thank you!
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