Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Impromptu and email

Status
Not open for further replies.

axeman66

Technical User
Apr 21, 2004
4
US
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.

Thanks in advance!

Mike
 
You can do with Microsoft outlook as follows:

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

soi la, soi carre
 
Thanks guys for the quick response.

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?

Thanks again, Mike
 
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


soi la, soi carre
 
ok, thanks alot for the help drlex & dm21!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top