Monday, February 18, 2008

Sending EMails using CDO's

CDO 's are command data objects used to send Emails from SMTP server.
Before using this objects ,we need to configure the SMTP server .
Using CDO objects
Simple EMail
Set myMail=CreateObject("CDO.Message") myMail.Subject=ReportName myMail.From="HarikaWorks" myMail.To="harika.04@Gmail.com" mymail.cc="OtherReceipints@abc.com" myMail.Bcc= "OtherReceipints1@abc.com" myMail.Replyto="admin@abc.com" mymail.send()



Email with attachments
Set myMail=CreateObject("CDO.Message") myMail.Subject=ReportName myMail.From="HarikaWorks" myMail.To="harika.04@Gmail.com" mymail.cc="OtherReceipints@abc.com" myMail.Bcc= "OtherReceipints1@abc.com" myMail.Replyto="admin@abc.com" myMail.AddAttachment "D://Images/image1.gif" mymail.send()


Zip attachments in Email
Set myMail=CreateObject("CDO.Message") myMail.Subject=ReportName myMail.From="HarikaWorks" myMail.To="harika.04@Gmail.com" mymail.cc="OtherReceipints@abc.com" myMail.Bcc= "OtherReceipints1@abc.com" myMail.Replyto="admin@abc.com"
Scurdir=oFs.GetAbsolutePathName("") strcommand="winzip32.exe" Set objShell=CreateObject("WScript.Shell") strpath= "D:\\images\charts\Reports.zip" strdestination= ScurDir & "\" & sFullFileName
strcommand= strcommand & " " & " -a" & " " & strpath & " " & strdestination objShell.Run strCommand, 0, True 'wait! myMail.AddAttachment "D://Images/image1.gif" mymail.send()

No comments:

Post a Comment