Login   /   Register

Sending a Text Email with an Attached File

Rate this article
     1 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 5
Loading ... Loading ...
April 1st, 2008 by daniva

Windows 2000 and Windows XP use CDO messaging as a replacement for CDONTS. Sending email with CDO is a simple task.
First we create a reference to the CDO component

Set objMessage = CreateObject("CDO.Message") 


then fill-in Sender, Subject and Recipient (To) fields of the headers and the body text which can be either plain text or HTML. You can also add a file attachment. You then use the Send method to send the email.

Set oMessage = CreateObject("CDO.Message") 
oMessage.Subject = "Example CDO Message" 
oMessage.Sender = "me@my.com" 
oMessage.To = "test@test.com" 
oMessage.TextBody = "This is some sample message text." 
oMessage.AddAttachment "c:\temp\readme.txt"
oMessage.Send

Posted in CDO Component

6 Responses to “Sending a Text Email with an Attached File”

  1. Haridas Says:

    [+]

    I wonder how the message is sent. There is no reference to the smtp server or exchange server. I get the following error : "The "S... ...

  2. Haridas Says:

    [+]

    Nevermind. I figured it out. You may have to add this also before the line oMessage.Subject.... Thanks for this article daniva. :)... ...

  3. SENTHIL Says:

    [+]

    Can any one help in getting the Emails if any problem in script/error while running in script automaticallly to the recipients add... ...

  4. SENTHIL Says:

    [+]

    please advise me to have a database based framework rather getting data from XL.Currently I am using XL based framework and i face... ...

  5. vvkalkundri Says:

    [+]

    Is there any pre-condition for setting Report Server to be used for the Email. I am not able to send the emails. It says " The tra... ...

  6. maheswar81 Says:

    [+]

    Outlook express should be installed in your server or m/c. Then Set objMessage = CreateObject("CDO.Message") objMessa... ...

Leave a Reply

You must be logged in to post a comment.

This article was viewed 747 times