El TecnoBaúl de Kiquenet

Kiquenet boring stories

Posts Tagged ‘smtp system.net.mail gmail’

Smtp Mail utilizando Gmail

Posted by kiquenet en 5 abril 2010

Código fuente:

Imports System.Net.Mail

Imports System.Net.Mail.MailMessage

Imports System.Net.NetworkCredential


    Dim mail As New MailMessage()

    Dim msgBody As String

    Dim smtp As New SmtpClient

    mail.From = New MailAddress(ur-gmail-account@gmail.com, "display name")


    mail.Subject = Subject

    mail.Body = msgBody

    mail.IsBodyHtml = True ' This is to enable HTML in your email body

    mail.ReplyTo = New MailAddress(“reply-to-email-address“)  ' This is optional, it allows you to add Reply To email address.

   smtp.Host = "smtp.gmail.com"

   smtp.Port = 587; // 465; // 587

   smtp.EnableSsl = True

   smtp.Credentials = New System.Net.NetworkCredential(ur-gmail-account@gmail.com, "gmail-password")


   lblFlag.Text = "Your Message has beent sent."


Note: We can build this email form AJAX based, by putting the content in an UpdatePanel control, and add the button “send” as a trigger.

<smtp deliveryMethod="Network">
<network host="smtp.gmail.com" userName="your_username" password="your_ password" port="465"/>


smtp.gmail.com (use authentication)

Use Authentication: Yes

Port for TLS/STARTTLS: 587

Port for SSL: 465

Referencia: http://geekswithblogs.net/aymanfm/archive/2006/03/09/71868.aspx

Posted in .NET | Etiquetado: | Leave a Comment »