Capt. Horatio T.P. Webb
 
CDONT -- Emails from ASP

Parks -- SPRING 2009
Last Updated 6 PM 4/29/2009

Using ASP it is easy to send emails. First you create a mail object by saying:

Set CDONT_object_name = Server.CreateObject("CDONTS.NewMail")

Then the following object properties can be defined:

  1. CDONT_object_name.To = "email address (optional name to appear)"

    This property is REQUIRED. If you follow the email address by (optional name to appear) this name appears on the email in the "To" field. This optional name enclosed in parentheses MUST be inside the quotes. You may use more than one email address by separating the addresses with a semicolon.

  2. CDONT_object_name.From "email address (optional name to appear)"

    This property is REQUIRED.If you follow the email address by (optional name to appear) this name appears on the email in the "From" field. This optional name enclosed in parentheses MUST be inside the quotes.

  3. CDONT_object_name.Cc = "email address"

    Copies of the email is sent to this address. You may use more than one email address by separating the addresses with a semicolon.

  4. CDONT_object_name.Bcc = "email address"

    This field sends blind copies of the email to the recipients listed. This means that recipients receiving blind copies DO NOT see the other email recipients who were sent the same email. You may use more than one email address by separating the addresses with a semicolon.

  5. CDONT_object_name.Subject = "some text"

    The text in quotes appears in the recipients Subject field

  6. CDONT_object_name.BodyFormat = 0 (zero) | 1 (one)

    If you wish the format of the email to be HTML you use as 0 (zero). For plain text use a 1 (one). If you do not specify this property, the Body format is defaults to 1 (i.e., plain text).

  7. CDONT_object_name.MailFormat = 0 (zero) | 1 (one)

    If you set the .BodyFormat to zero (i.e., HTML) you will also need to set this property to zero.

  8. CDONT_object_name.Importance = 0 | 1 | 2

    This sets the importance of the email. 0=low, 1=normal (the default) , 2=high.

  9. CDONT_object_name.Value("Reply-To")="email address"

    This sets an alternative email address for reply. If the recipient clicks "reply" this alternative email address is used -- NOT the one specified in the "from" property.

  10. CDONT_object_name.Body = "text string

    This sets the text to appear in the body. When sending text (not HTML) you may wish to use the character pair: Chr(13)+Chr(10) to terminate lines (i.e., create short lines). Otherwise the text will appear as one long string.

  11. CDONT_object_name.AttachFile = "path/filename", "name to appear in the email"

    To attach a file to the email, the path/filename must appear in quotes. If you include a name in parentheses, the name appears in the email rather than the path/filename. This second parameter is optional.

  12. CDONT_object_name.AttachURL = "path/filename", "name to appear in the body tag"

    This syntax provides the ability to include an attachment (e.g., an image) in the email body. You would assign the BodyFormat and MailFormat both to 0 (i.e., HTML). Then inside the .body text you would use the name to appear in the body tag to reference the file to appear.

    e.g., if you wish to display an image in body of the email (i.e., in the HTML) you would use:

    1. CDONT_object_name.Mail.BodyFormat = 0
    2. CDONT_object_name.MailFormat = 0
    3. CDONT_object_name.AttachURL = "c:\fred\captsm.gif" , "captsm.gif"
    4. CDONT_object_name.Body = "... <img src='captsm.gif'> ..."

  13. CDONT_object_name.Send

    This sends the email.

    You should remember to destroy the email object when done:

    Set CDONT_object_name = nothing

    Further any user executing the asp program (normally the anonymous Internet user named "IUSR_Internet") containing the CDONT commands must have privileges (read and execute) to the directory "inetpub\mailroot".