But what will make this code completely functional in the event that the smtp server you are using is not local (as most hosted solutions offer) is to add the following code:
Dim basicAuthenticationInfo As _ New System.Net.NetworkCredential("username", "password") 'Put your own, or your ISPs, mail server name onthis next line mailClient.Host = "Mail.RemoteMailServer.com" mailClient.UseDefaultCredentials = False mailClient.Credentials = basicAuthenticationInfo mailClient.Send(myMail)
This code will work in cases where the smtp server is local or remote on the machine your web site is running on.
The updated code looks like:
Dim myMail As MailMessage = New MailMessage
myMail.From = "from@youremail.com" 'the "from" address
myMail.To = "to@theiremail.com" 'the "to" address
myMail.Subject = "Howdy" 'your "subject"
myMail.Body = "Just wanted to say Hi. How are you?"'message body
[b]Dim basicAuthenticationInfo As _
New System.Net.NetworkCredential("username", "password")
'Put your own, or your ISPs, mail server name onthis next line
mailClient.Host = "Mail.RemoteMailServer.com"
mailClient.UseDefaultCredentials = False
mailClient.Credentials = basicAuthenticationInfo
mailClient.Send(myMail)[/b]
Dim basicAuthenticationInfo As _
New System.Net.NetworkCredential("username", "password")
'Put your own, or your ISPs, mail server name onthis next line
mailClient.Host = "Mail.RemoteMailServer.com"
mailClient.UseDefaultCredentials = False
mailClient.Credentials = basicAuthenticationInfo
mailClient.Send(myMail)
This code will work in cases where the smtp server is local or remote on the machine your web site is running on.
The updated code looks like: