HOWTO: CDONTS/VBS Send an Email with an attachment


Here is a sample for sending mail using CDONTS...


Please note that CDONTS is not supported on Windows 2003 and later:


' HOWTO: CDONTS/VBS Send and Eamil with an attatchment
'
' For more information on sending an email using CDONTS see:
'    NewMail Object (CDONTS Library)
'   http://msdn.microsoft.com/library/en-us/cdo/html/_denali_newmail_object_cdonts_library_.asp?frame=true


    Dim objMail 'As CDONTS.NewMail
    Set objMail = CreateObject("CDONTS.Newmail")
    objMail.BodyFormat = 1 ' 0-The message is in MIME format, 1-The message is in uninterrupted plain text.
    objMail.Importance = 1 ' 0-Low importance, 1-Normal Importance(Default),2-High Importance
    'objMail.From = "somebody@microsoft.com"              ' TODO: Change this to the address you are sending from
    'objMail.To = "someoneelse@microsoft.com"             ' TODO: Change this to the address you are sending to
    objMail.Subject = "Are you aready for the meeting?"   ' TODO: Change this to the Subject you want to use


    objMail.Body = "Don't forget the cookies!"            ' TODO: Change this to the body of the message.


     ' TODO: Comment out the next line if you are not sending an attatchement.
    objMail.AttachFile "C:\download\myfile"               ' TODO: Change this to the path and name of the file you are attatching.
    objMail.Send
    Set objMail = Nothing

Comments (0)

Skip to main content