Simple Send Email Subroutine

Discussion in 'ASP.NET Code Snips' started by BluJag, Mar 17, 2007.

  1. BluJag

    BluJag Perch

    17 March 2007

    Tested in version 1 (see next post for verson 2) Neither tried with an AOL address yet - will be interested to hear if it works OK.

    Dim MyMail As New System.Web.Mail.MailMessage
    Dim SMTP As System.Web.Mail.SmtpMail

    Dim Email as string
    Dim Subject as string
    Dim MsgTxt as string

    With MyMail

    .To = Email
    .From = "[email protected]"
    .Subject = Subject
    .Body = MsgTxt
    .Bcc = "[email protected]"
    .Fields.Item("") = 25
    .Fields.Item("") = 2
    .Fields.Item("") = ""
    .Fields.Item("") = "[email protected]"
    .Fields.Item("") = "password"
    .Fields.Item("") = 1
    .Fields.Item("") = 25

    End With

    With SMTP
    .SmtpServer = ""
    End With
  2. BluJag

    BluJag Perch

    Tested in version 2

    Dim Credential As New System.Net.NetworkCredential("[email protected]", "password")

    Dim MyMail As New System.Net.Mail.MailMessage

    Dim Client As New System.Net.Mail.SmtpClient()

    Client.Host = ""

    Client.Credentials = Credential

    Dim Email As New System.Net.Mail.MailMessage
    With Email
    .From = New System.Net.Mail.MailAddress("[email protected]")
    .To.Add("[email protected]")
    .CC.Add("[email protected]")
    .Bcc.Add("[email protected]")
    .ReplyTo = New System.Net.Mail.MailAddress("[email protected]")
    .Subject = "Your subject"
    .IsBodyHtml = False
    .Body = "Your message text etc"

    End With



    Catch ex As Exception
    'some processing code here to handle errors
    End Try

Share This Page

JodoHost - 26,000 hosting end-users in 100 countries
Plesk Web Hosting
VPS Hosting
H-Sphere Web Hosting
Other Services