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