J
Joe
I am attempting to send an SMTP mail from my VB.NET program
using the code below. The code compiles and runs fine executes with
no errors, but I am sending to one of my alternate addresses and the e-
mail is not arriving.
I was thinking that if there was something fundamentally wrong
with my host servername or credentials, that the SMTPClient class
would throw an SMTPException, but it does not. According to Microsoft
Outlook, my outgoing server does not require authentication, and
sending e-mails from there works fine for me.
Can anyone tell me what I am doing wrong in my code below?
Private Sub SendEMailResponse(ByVal sReplyToAddress As String, ByVal
sResponseText As String)
Dim smtpCrawler As New SmtpClient
Dim ResponseEMail As New MailMessage
Dim FromAddress As New MailAddress("(e-mail address removed)",
"My Display Name")
Dim ToAddress As New MailAddress(sReplyToAddress)
smtpCrawler.Host = "smtp.west.cox.net"
smtpCrawler.Port = 25
With ResponseEMail
.From = FromAddress
.To.Add(ToAddress)
.Subject = "This is a test"
.Body = sResponseText
End With
Try
smtpCrawler.UseDefaultCredentials = False
smtpCrawler.Credentials = New
NetworkCredential("MyUsername", "MyPassword")
smtpCrawler.Send(ResponseEMail)
MsgBox("E-mail response successfully sent.")
Catch ex As SmtpException
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
using the code below. The code compiles and runs fine executes with
no errors, but I am sending to one of my alternate addresses and the e-
mail is not arriving.
I was thinking that if there was something fundamentally wrong
with my host servername or credentials, that the SMTPClient class
would throw an SMTPException, but it does not. According to Microsoft
Outlook, my outgoing server does not require authentication, and
sending e-mails from there works fine for me.
Can anyone tell me what I am doing wrong in my code below?
Private Sub SendEMailResponse(ByVal sReplyToAddress As String, ByVal
sResponseText As String)
Dim smtpCrawler As New SmtpClient
Dim ResponseEMail As New MailMessage
Dim FromAddress As New MailAddress("(e-mail address removed)",
"My Display Name")
Dim ToAddress As New MailAddress(sReplyToAddress)
smtpCrawler.Host = "smtp.west.cox.net"
smtpCrawler.Port = 25
With ResponseEMail
.From = FromAddress
.To.Add(ToAddress)
.Subject = "This is a test"
.Body = sResponseText
End With
Try
smtpCrawler.UseDefaultCredentials = False
smtpCrawler.Credentials = New
NetworkCredential("MyUsername", "MyPassword")
smtpCrawler.Send(ResponseEMail)
MsgBox("E-mail response successfully sent.")
Catch ex As SmtpException
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End Sub