Sending email via a local email relay or local email server.-VBForums
Results 1 to 1 of 1

Thread: Sending email via a local email relay or local email server.

Threaded View

  1. #1

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

    Smile Sending email via a local email relay or local email server.

    Sending email via a local email relay or local email server.

    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("yourUserName", "yourPassword")
    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("smtpserver", 25)
    11.     client.Credentials = loginInfo
    12.     client.Send(msg)
    13. Catch ex As SmtpException
    14.     StatusLabel.Visible = True
    15.     StatusLabel.Style.Add("color", "#CC0033")
    16.     StatusLabel.Text = "The following error occurred: " + "<br /><br />" + ex.Message
    17.     Return
    18. End Try
    19.  
    20.     StatusLabel.Visible = True
    21.     StatusLabel.Style.Add("color", "#009966")
    22.     StatusLabel.Text = "Email sent successfully."
    Last edited by met0555; Jul 17th, 2008 at 01:34 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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.