Add To Your Favorites  Digg This Page  Google Bookmarks  del.icio.us  StumbleUpon  Share On FaceBook  
 
Send Google Email Using ASP.NET    9/16/2008

Send Google Email Using ASP.NET

Send Google Email Using ASP.NET

Google Mail is a free (or inexpensive depending on options) way to host your small business email using your own domain.  http://www.google.com/apps/intl/en/business/editions.html It offers reliable and secure POP/SMTP access for your favorite email client and a great webmail interface.  Additionally it has good deliverability and excellent spam filtering.  Sending Google mail using ASP.NET if pretty similar to sending standard SMTP email with ASP.NET the following can be easily implemented in any existing project.

Imports System.Net.Mail

 

Sub SendGoogleMail(ByVal myFromAddress As String, ByVal myFromAddressDisplay As String, ByVal myToAddress As String, ByVal mySubject As String, ByVal myBody As String, ByVal ID As String, ByVal Password As String)

    Dim myMessage As New MailMessage

    Dim SMTPSERVER As New SmtpClient

    myMessage.From = New MailAddress(myFromAddress, myFromAddressDisplay)

    myMessage.ReplyTo = New MailAddress(myFromAddress)

    myMessage.To.Add(New MailAddress(myToAddress))

    myMessage.Cc.Add(New MailAddress(myCCAddress))

    myMessage.Bcc.Add(New MailAddress(myBCCAddress))

    myMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure

    myMessage.IsBodyHtml = True

    myMessage.Priority = MailPriority.High

    myMessage.Subject = mySubject

    myMessage.Body = myBody

    SMTPSERVER.DeliveryMethod = SmtpDeliveryMethod.Network

    SMTPSERVER.Host = "smtp.gmail.com"

    SMTPSERVER.EnableSsl = True

    SMTPSERVER.Port = 587

    Dim basicAuthenticationInfo As New System.Net.NetworkCredential(ID, Password)

    SMTPSERVER.Credentials = basicAuthenticationInfo

    SMTPSERVER.Send(myMessage)

    myMessage.Dispose()

    myMessage = Nothing

    SMTPSERVER = Nothing

End Sub

 

Your Comment
Your Signature

© Copyright 2008 All rights reserved. Edgar E. Kneel