SMTP: Bad Sequence of Commands

S

Scott McNair

Hi,

I'm trying to generate an email programmatically, by sending it to our SMTP
server. However I get the following error:

Bad sequence of commands. The server response was: Bad sequence of commands

Here's the code snippet I'm using to send the message:

Public Sub SendMail(ByVal strFrom As String, ByVal strTo As String,
ByVal strSubject As String, ByVal strBody As String, ByVal Host As String,
ByVal Port As Integer, ByVal UserName As String, ByVal Password As String)
Dim Email As New System.Net.Mail.MailMessage(strFrom, strTo)
Email.Subject = strSubject
Email.Body = strBody & vbCrLf & vbCrLf & "Message generated at: " &
Now.ToString
Dim mailClient As New System.Net.Mail.SmtpClient()
Dim basicAuthenticationInfo As _
New System.Net.NetworkCredential(UserName, Password)
mailClient.Host = Host
mailClient.Port = Port
mailClient.UseDefaultCredentials = False
mailClient.Credentials = basicAuthenticationInfo
mailClient.Send(Email)
End Sub
 
S

Scott McNair

Hi,

I'm trying to generate an email programmatically, by sending it to our
SMTP server. However I get the following error:

Bad sequence of commands. The server response was: Bad sequence of
commands

Found the problem... apparently our mail server runs on an alternate port,
and there's SOMETHING running on port 25 which generates an error every
time the EHLO command is sent to it.

Oops!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top