Sending E-Mails with ASP Pages

Version 

   ASP3

Description

   This code will show how to send emails with CDO, because it's available to everyone
   and components work in a very similar way. First we have to create instance of the
   NewMail object.

Comments

   Sending an email with asp is fairly easy, all you need is CDONTS (Collaboration Data
   Objects for NT Server, installed with IIS), or a special component like SMTPmail by
   SoftArtisans, or AspEmail ( free ) by Persits Software Inc (there are more available).
   E-Mail Code :

 <%
  Option Explicit

  Dim objCDOMail
  Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
  objCDOMail.To = "[email protected]"   'the destination
  objCDOMail.From = "[email protected]"   'the sender
  objCDOMail.cc = "[email protected]"   'carbon copy

  Dim txtBody
  txtBody = "This email has been sent by an asp script"
  objCDOMail.Subject = "CDONTS"   'the subject
  objCDOMail.Body = txtBody   'the body
  objCDOMail.Send   'fire off the email
 %>

   There's more :

  <%
    objCDOMail.AttachFile("c:\wwwroot\mysite\" & _
    "MyAttachement.doc", "pricelist.doc")
    objCDOMail.Bcc("[email protected]")
    objCDOMail.Importance = 1
  %>

  • The first rule defines an attachment ("PATH\TO\FILE", filename_that_appears)
  • The second rule sends a blind carbon copy
  • The third rule specifies the message's importance
      Importance:
    • 0 -> low
    • 1 -> default
    • 2 -> high

 





   Mail Us


This site is best viewed at 800 x 600 resolution & IE 5 or above.
Copyright © 2001. All rights reserved.