From: Scott McNair on
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
From: Scott McNair on
Scott McNair <smcnair(a)beachexpress.takethispartout.com> wrote in
news:Xns9DA7697AEA99Edonquixote235gmailco(a)207.46.248.16:

> 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!