Click here to Skip to main content
Click here to Skip to main content

Sending Authenticated e-mail in ASP.NET 2.0

, 5 Feb 2006
Rate this:
Please Sign up or sign in to vote.
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

Share

About the Author

Catalin Radoi

United States United States
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

Comments and Discussions

 
Questionhow to mange SmtpPermission or security policy Pinmemberseedawi10-Sep-08 13:41 
Generalpls help Pinmemberwasif_Muhammad22-Feb-07 2:19 
GeneralSending Authenticated e-mails in ASP.NET 2.0 by Using PinmemberAmirK116-Jul-06 19:08 
GeneralRe: Sending Authenticated e-mails in ASP.NET 2.0 by Using Pinmembersvkoli1-Jan-07 15:21 
QuestionASP.Net 1.1 Pinmemberfarajallah9813-Mar-06 23:54 
AnswerRe: ASP.Net 1.1 PinmemberCatalin Radoi14-Mar-06 1:28 
GeneralExchange Server PinmemberAzel Low6-Feb-06 20:41 

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.

| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 6 Feb 2006
Article Copyright 2006 by Catalin Radoi
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid