M
mickey
I tried that and it got me past the original problem but now it just fails
to send. Something about not being able to connect to the server. I was able
to ping the server so maybe I should try increasing the timeout.
Thanks
Mickey
You need to instantiate a NetworkCredential object like this:
Dim cred as New NetworkCredential _
(username, password)
emailClient.Credentials = cred
HTH,
Onur Güzel
to send. Something about not being able to connect to the server. I was able
to ping the server so maybe I should try increasing the timeout.
Thanks
Mickey
Hi
I'm trying to add simple email capability to a program I wrote but when I
send the mail the responce from the server indicates thet I need to use
authenticain.
I have no clue as to how to do that. Here is the code I'm using. Can
anyone
help please?
Thanks
Mickey
Public Sub SendMail(ByVal strFrom As String, ByVal strTo As String, ByVal
strSubject As String, _
ByVal strBody As String, ByVal strSMTPServer As String)
Dim FromAddress As New System.Net.Mail.MailAddress(strFrom)
Dim ToAddress As New System.Net.Mail.MailAddress(strTo)
'send the email
Try
Dim insMail As New MailMessage()
With insMail
.From = FromAddress
.To.Add(ToAddress)
.Subject = strSubject
.Body = strBody
End With
Dim emailClient As New SmtpClient(strSMTPServer)
Try
emailClient.Send(insMail)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Catch e As Exception
MsgBox(e.Message)
End Try
End Sub
You need to instantiate a NetworkCredential object like this:
Dim cred as New NetworkCredential _
(username, password)
emailClient.Credentials = cred
HTH,
Onur Güzel