Fast2Host Logo

Email

Sending email from a webpage using ASP.Net

All mail sent using Fast2host servers must use authentication.
This is an example of adding authentication to your mail script using System.Web.Mail:


Protected Sub SendMail()
Dim mm As New System.Net.Mail.MailMessage
mm.Subject = "Email Subject Here"
mm.IsBodyHtml = False ' If using True, ensure that mm.Body is correctly formatted HTML (example below uses plain text)


' create the body text in the email
Dim sb_body As New StringBuilder
sb_body.AppendLine("Dear Person,")
sb_body.AppendLine("")
sb_body.AppendLine("This email was sent using ASP.NET from Fast2Host.com's hosting package")
sb_body.AppendLine("")
sb_body.AppendLine("Kind Regards")
mm.Body = sb_body.ToString


' add recipient(s)
mm.To.Add(New System.Net.Mail.MailAddress("SendTo@Address.Here", "Recipients Name")) ' you can re-use this line to add more recipients
mm.From = New System.Net.Mail.MailAddress("Sender@Address.Here", "Sender's Name") ' this can be any email address you like


' Send via Fast2Host server
Dim mc As New System.Net.Mail.SmtpClient
mc = New System.Net.Mail.SmtpClient("mail.mydomain.com") 'replace mydomain.com with your domain name
mc.UseDefaultCredentials = False
mc.Credentials = New System.Net.NetworkCredential("user@mydomain.com", "MyPassword") 'this MUST be a valid account created within your control panel
mc.Send(mm)
End Sub



Maintain peace of mind with UK based support

Email any time or call 01480 26 00 00 014 80 26 00 00