Inviare un'email con autenticazione in ASP.NET 2.0

by enrico 27. March 2009 13:09

Questo semplice codice illustra come poter inviare un’email da ASP.NET 2.0 e successivi con l’autenticazione del server SMTP.

   1: ' crea un nuovo oggetto MailMessage e specifica mittente e destinatario
   2: Dim Email As New System.Net.Mail.MailMessage( _
   3:    "info@vbdotnet.it", "info@pippo.com")
   4: Email.Subject = "test subject"
   5: Email.Body = "this is a test"
   6: Dim mailClient As New System.Net.Mail.SmtpClient()
   7:  
   8: ' questo oggetto salva le credenziali per l'accesso al server SMTP
   9: Dim basicAuthenticationInfo As _
  10:    New System.Net.NetworkCredential("username", "password")
  11:  
  12: ' inserire qui il tuo server remoto o quello del tuo providers
  13: mailClient.Host = "Mail.RemoteMailServer.com"
  14: mailClient.UseDefaultCredentials = False
  15: mailClient.Credentials = basicAuthenticationInfo
  16: mailClient.Send(Email)

Ciao

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

asp.net | vb.net | web

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by Esia Software 1.4.0.0

Informazioni sull'autore

Sono un cittadini di Trieste, ho 33 anni e faccio lo sviluppatore nella mia azienda che si chiama Esia Software.

Commenti recenti

Comment RSS

Post recenti

Calendar

<<  May 2012  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar

Info legali

Le opinioni espresse in questo blog sono strettamente personali e ogni persona è responsabile dei commenti che inserisce.

RecentComments

Comment RSS