Skip to Content
0
Former Member
Apr 21, 2009 at 04:01 PM

Schedule webi report to destination to Inbox AND send email notification

82 Views

I'm writing a new process that will schedule a webi report. The output of the report needs to be delivered to multiple user's BO Inboxes AND an email notification (without the report attached) needs to be sent telling them that they have a new report to view in their Inbox. Trying to mimic how this is done via CMC Schedule - Notification and Destination tabs.

I can get it to deliver the report to the Inbox and I can get it to send an email seperately, but the problem I'm running into is that I can't get it to do both in the same process. Here is the code snippet that I've written. Any assistance would be appreciated.

// Retrieve the managed plugin

IInfoObjects managedInfoObjects = infoStore.query("Select SI_DEST_SCHEDULEOPTIONS, SI_PROGID From CI_SYSTEMOBJECTS Where SI_NAME = 'CrystalEnterprise.Managed'");

IInfoObject infoObject = (IInfoObject)managedInfoObjects.get(0);

IDestinationPlugin destinationPlugin = (IDestinationPlugin)infoObject;

IManaged managed = (IManaged)destinationPlugin;

// Set the destination to inbox

IManagedOptions managedOptions = (IManagedOptions)managed.getScheduleOptions();

managedOptions.setDestinationOption(IManagedOptions.CeDestinationOption.ceInbox);

managedOptions.setSendOption(IManagedOptions.CeManagedSendOption.ceCopy);

managedOptions.setIncludeInstance(true);

managedOptions.getDestinations().add(new Integer(ditUserID1));

managedOptions.getDestinations().add(new Integer(ditUserID2));

managedOptions.getDestinations().add(new Integer(ditUserID3));

scheduleInfo.getDestination().setFromPlugin(managed);

// Retrieve the smtp plugin. to send email notification

IInfoObjects smtpInfoObjects = infoStore.query("Select SI_DEST_SCHEDULEOPTIONS, SI_PROGID From CI_SYSTEMOBJECTS Where SI_PARENTID = 29 AND SI_NAME = 'CrystalEnterprise.Smtp'");

IInfoObject smtpInfoObject = (IInfoObject)smtpInfoObjects.get(0);

IDestinationPlugin smtpDestinationPlugin = (IDestinationPlugin)smtpInfoObject;

// Set to email notification on success

ISMTP smtp = (ISMTP)smtpDestinationPlugin;

ISMTPOptions smtpOptions = (ISMTPOptions)smtp.getScheduleOptions();

smtpOptions.setServerName("mailhost.XXXXX.net");

smtpOptions.setPort(25);

smtpOptions.setDomainName("XXXXX.com");

smtpOptions.setSenderAddress("XXXXX.com");

smtpOptions.setSubject("Indicative Data Update Reports");

smtpOptions.getToAddresses().add("XXXXX.com");

smtpOptions.setMessage("Test Message");

smtpOptions.setSMTPAuthenticationType(CeSMTPAuthentication.NONE);

scheduleInfo.getNotifications().getDestinationsOnFailure().add("New");

scheduleInfo.getDestination().setFromPlugin(smtp);

Edited by: Shannon Maret on Apr 21, 2009 7:02 PM