How do I send email from ASP using SMTP Authentication in ASP.NET1.1

The following code is developed in VB:

Sub Button1_Click(sender As Object, e As EventArgs)
' Build a MailMessage
Dim mailMessage As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
mailMessage.From = "from_email@domain.com"
mailMessage.To = "to_email@domain.com"
mailMessage.Subject = "Email Subject"
mailMessage.Body = "EMail Message Body"
mailMessage.BodyFormat = System.Web.Mail.MailFormat.Html

'Authentication
mailMessage.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
mailMessage.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
mailMessage.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
mailMessage.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "user@domain.com"
mailMessage.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"

System.Web.Mail.SmtpMail.SmtpServer = "mail.domain.com"
System.Web.Mail.SmtpMail.Send(mailMessage)
End Sub

  • 232 Users Found This Useful
Was this answer helpful?

Related Articles

General ASPWebHosting Mail Server Information

ASPWebHosting.com.au provides all customers with access to send and receive internet email using...

What do you mean by Catch All Email ?

In short, the catch-all email function allows you to receive all incoming email that is addressed...

What do you mean by Email Forwarding?

Basically email forwarding allows you to create a unique email account which will...

How do my email address user update their password?

Follow this instruction Log into ASPWebHosting webmail (http://mail.yourdomainname.com)...

I try to send and email throught Outlook but i got the error message "RELAY not allowed" why?

You have to enabled SMTP Authentication **Important - Always use this format username@domain.com...