Click here to Skip to main content
Licence 
First Posted 5 Feb 2006
Views 46,582
Bookmarked 35 times

Sending Authenticated e-mail in ASP.NET 2.0

By | 5 Feb 2006 | Article
How to send authenticated e-mail from ASP.NET (login/password)

Login to an SMTP server and send an email

There are many articles on how to send authenticated email in ASP.NET 2.0, but here's how to send an email using a SMTP server that requires authentication.

(Imports System.Net)

Dim client As New SmtpClient("smtp.server.com") 'your SMTP server
client.UseDefaultCredentials = False

'Your username and password to login
client.Credentials = New Net.NetworkCredential("username", "password") 
client.DeliveryMethod = SmtpDeliveryMethod.Network
Dim Mail As New MailMessage("from@email.com", "to@email.com", _
        "This is my subject", _
        "This is my pretty, yet boring and useless message")
Mail.IsBodyHtml = True

Try
    client.Send(Mail)
Catch ex As Exception
    Response.Write(ex.Message) 'Write error message
    Exit Sub
End Try

'successful

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Catalin Radoi



United States United States

Member

I am a software programmer from Bucharest, Romania.
I am 24 years old and I am very pleased with my job at Elven Soft, a company specialized in custom software development and web design

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Questionhow to mange SmtpPermission or security policy Pinmemberseedawi13:41 10 Sep '08  
Generalpls help Pinmemberwasif_Muhammad2:19 22 Feb '07  
GeneralSending Authenticated e-mails in ASP.NET 2.0 by Using PinmemberAmirK119:08 16 Jul '06  
GeneralRe: Sending Authenticated e-mails in ASP.NET 2.0 by Using Pinmembersvkoli15:21 1 Jan '07  
QuestionASP.Net 1.1 Pinmemberfarajallah9823:54 13 Mar '06  
AnswerRe: ASP.Net 1.1 PinmemberCatalin Radoi1:28 14 Mar '06  
GeneralExchange Server PinmemberAzel Low20:41 6 Feb '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 6 Feb 2006
Article Copyright 2006 by Catalin Radoi
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid