SMTP and Secure Password Authentication (SPA)

  • Thread starter Thread starter Cedric Fairweather
  • Start date Start date
C

Cedric Fairweather

I need help sending messages to mail systems that requre SPA. Here is a code
snippit but it does not work. Thanks in advance for your help.
Cedric

Dim Mail As New System.Net.Mail.MailMessage
Mail.From = New MailAddress(FromEMailAddress, FromName)
Mail.To.Add(New MailAddress(SendTo))
Mail.Subject = Subject
Mail.Body = body
Dim Smtp = New SmtpClient(SMTPServer, SMTPPort) 'SMTPServer =
smtp.somewhere.com
Dim nc As New NetworkCredential

If String.IsNullOrEmpty(SmtpUserID) = False Then
If String.IsNullOrEmpty(SmtpPassword) = False Then
Smtp.Credentials = New Net.NetworkCredential(SmtpUserID, SmtpPassword)
End If
End If

If UseSSL Then
Smtp.EnableSsl = True
End If

If UseSPA Then
nc = New Net.NetworkCredential(SmtpUserID, SmtpPassword)
'AuthTypes: "Basic", "NTLM", "Digest", "Kerberos", "Negotiate" string
authType = "Basic"
Smtp.Credentials = nc.GetCredential(SMTPServer, SMTPPort, "NTLM")
ELSE

End If

Smtp.Send(Mail)
 
Back
Top