i am using the following code to test the sending of emails via smtp: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim strFrom = "[email protected]" Dim strTo = "[email protected]" Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New MailAddress(strTo)) MailMsg.BodyEncoding = Encoding.Default MailMsg.Subject = "User Registration" MailMsg.Body = "User Name: jrees" MailMsg.Priority = MailPriority.High MailMsg.IsBodyHtml = True Dim smtp As New SmtpClient smtp.Host = "localhost" smtp.Send(MailMsg) End Sub however when i open the page containing this i dont get any error messages but the email doesn't seem to get sent. i've tried looking at the anti-spam folders to see if the email got sent but then got treated as spam, but to no avail. any help would be gratefully appreciated John
Hi, If you need to trim the To and From try and do it before the Sub. Then write your build like this: Dim MailMsg As New MailMessage(strFrom, strTo) Make sure you have these also: Imports System.Net.Mail Imports System.Net
many thanks - i have just now resolved this issue. it was actually down to the "from" address being invalid thanks again John