Results 1 to 5 of 5

Thread: Sending email via Google's GMail.

Threaded View

  1. #1

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Thumbs up Sending email via Google's GMail.

    Sending email via Google's GMail.

    Works on ASP.NET 2.0 and 3.5

    asp Code:
    1. Imports System.Net
    2. Imports System.Net.Mail
    3.  
    4. Dim loginInfo As New NetworkCredential("[email protected]", "yourGMailPassword")
    5. Dim msg As New MailMessage(EmailFromTextBox.Text, EmailToTextBox.Text, EmailSubjectTextBox.Text, EmailBodyTextBox.Text)
    6. msg.IsBodyHtml = True
    7. StatusLabel.Visible = False
    8.  
    9. Try
    10.     Dim client As New SmtpClient("smtp.gmail.com", 587)
    11.     client.EnableSsl = True
    12.     client.UseDefaultCredentials = false
    13.     client.Credentials = loginInfo
    14.     client.Send(msg)
    15. Catch ex As SmtpException
    16.     StatusLabel.Visible = True
    17.     StatusLabel.Style.Add("color", "#CC0033")
    18.     StatusLabel.Text = "The following error occurred: " + "<br /><br />" + ex.Message
    19.     Return
    20. End Try
    21.  
    22.     StatusLabel.Visible = True
    23.     StatusLabel.Style.Add("color", "#009966")
    24.     StatusLabel.Text = "Email sent successfully."
    Last edited by met0555; Jul 17th, 2008 at 01:30 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width