How do I send email from ASP using SMTP Authentication in ASP.NET?

Here is the code sample :
'Create a new MailMessage object and specify the"From" and "To" addresses
Dim Email As New System.Net.Mail.MailMessage( _
   "Brad.Kingsley@orcsweb.com", "Brad@KingsleyTeam.com")
Email.Subject = "test subject"
Email.Body = "this is a test"
Dim mailClient As New System.Net.Mail.SmtpClient()
'This object stores the authentication values
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(Email)
You can use your own email credentials, for example, your domain is abc.com then the email host : mail.abc.com and the username is youremail@abc.com

Esta resposta foi útil?

 Imprimir este Artigo

Leia também

How are the email accounts accessed?

...

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...

What do you mean by Email Forwarding?

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

I got Error 554 when send emails from Outlook

How to fix the problem: In Outlook, go to "Tools" and select "Email Accounts". Make sure "View...

General SeekDotNet Mail Server Information

...