Hi guys and thanks for the above posts.
I have been receiving an error about unable to send to non-local addresses - eg email outside of the domain. I have created the code below to fix the issue.
Create a button on the page and also a Label with the ID of 'EmailError'.
IMPORTS:
Quote:
Imports System.Net.Mail
Imports System.Net.NetworkCredential
|
CODE:
Quote:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim maMailfrom As New MailAddress("[FROM EMAIL]", "[FROM NAME]")
Dim maMailTo As New MailAddress("[TO EMAIL]", "[TO NAME]")
Dim mmEmail As New MailMessage(maMailfrom, maMailTo)
mmEmail.IsBodyHtml = False
mmEmail.Subject = "[SUBJECT]"
mmEmail.Body = "[MESSAGE]
TryDim smtpSend As New SmtpClient("smtp.[DOMAIN]") Dim credLogin As System.Net.NetworkCredential = New System.Net.NetworkCredential("[MAIL BOX EMAIL]", "[MAIL BOX PW]") smtpSend.Credentials = credLogin smtpSend.Send(mmEmail) Catch ex As ExceptionEmailError.Text = ex.ToString End Try
End Sub
|
Basically replace all the []'s with want you want. I hope this makes sense to you all!