Does anyone have the macro script for sending reports via email once they have executed. Generally, the reports are saved as .pdf files and have to be manually mailed to the recipient. I would like to automate this process further.
Dim ImpApp As Object
Dim htmlObj As Object
Dim ImpRep As Object
Dim objOutlook As Object
Dim objOutlookMsg As Object
Sub Main()
Set ImpApp = CreateObject("Impromptu.Application")
ImpApp.OpenCatalog "C:\Program Files\Cognos\cer1\samples\Impromptu\Reports\Great Outdoors Sales Data.CAT","Creator"
Set ImpRep = ImpApp.OpenReport("E:\Testcases\EdwinCruize\MyAttempt.imr")
ImpRep.ExportExcel "E:\Testcases\EdwinCruize\MyAttemptxls.xls"
ImpRep.CloseReport
Set ImpRep = Nothing
Set ImpApp = Nothing
Set htmlObj = Nothing
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
.To = "olivera.cosic@cognos.com"
.Subject = "Test"
.Body = "You received email with Excel report as the attachment"
.Attachments.Add ("E:\Testcases\EdwinCruize\MyAttemptxls.xls")
.Send
End With
Set objOutlook = Nothing
Set objOutlookMsg = Nothing
End Sub
Mike,
Check other threads on this topic (keyword search using email plus macro or script) for other email clients and tips. Note that recent versions of Outlook treat remote calls for email as potential virus/worms and won't send mail automatically.
lex
We currently use a close.mcx file to close the impromptu windows once a report has executed. We were thinking we could add this piece for sending email to the same close.mcx file, but I cannot seem to open any .mcx files with any text editor to attempt this and of course do some testing...any suggestions?
Mike,
the .mcx files are the compiled versions of the .mac files, which are opened and saved in cognos scripteditor. No need to muck around with .mcx files as if you run the .mac file, the .mcx version is generated.
Best to do all within the .mac file - set the variables and objects, open impromptu, run the reports and save as required, close impromptu and do further bits and bobs (eg emailing, excel formatting on the xls versions) prior to ending the macro.
lex
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.