re: Feel free to ask me questions
We are trying to send notification email to the user who scheduled the report. I know we can set up the server to notify the users email. I want to know if we can programmatically modify the email address and body through the SDK.
A:
You can change anything on the infoobject and it will be reflected when the object is run.
But this is a little risky to write code like this because you're changes may happen after the object has started to be scheduled, in which case your changes will not be picked up.
Here's sample code to set it when scheduling.
' This example shows how to modify the alert settings of the "Alerting" sample report '
Sub Alerts(IStore, ReportID)
Dim Result, Report
'Query for a report.
Set Result = IStore.Query("Select SI_PROCESSINFO From CI_INFOOBJECTS Where SI_ID = " & ReportID)
Set Report = Result.Item(1)
Dim ReportInterface
'Retrieve the report interface.
Set ReportInterface = Report.PluginInterface
Dim Alerts, Alert
'Specify the alert information that will be displayed in the alert notification email.
Set Alerts = ReportInterface.ReportAlerts
For Each Alert In Alerts
Alert.AlertSetSize = 3
'Select the default viewer URL
'You can also specify a specific viewer URL: "
http://webserver/virtualpath/viewer.csp?id=%SI_ID%"
Alert.ViewerURL = "%SI_VIEWER_URL%"
Next
'Schedule the report and send the report alerts to an SMTP server.
'Set the report's scheduling options.
Dim ScheduleInfo
Set ScheduleInfo = Report.SchedulingInfo
'Run the report once.
ScheduleInfo.Type = 0
'Run it right now.
ScheduleInfo.RightNow = True
'Set the destination's scheduling options.
Dim SMTP, SMTPSchedulingOptions
Set SMTP = IStore.Query("Select SI_DEST_SCHEDULEOPTIONS, SI_PROGID From CI_SYSTEMOBJECTS Where SI_PARENTID = 29 and SI_NAME='CrystalEnterprise.SMTP'").Item(1)
Set SMTPSchedulingOptions = SMTP.PluginInterface.ScheduleOptions
SMTPSchedulingOptions.DomainName = "yourdomain.com"
SMTPSchedulingOptions.Subject = "Alerts for sales report"
SMTPSchedulingOptions.ToAddresses.Add ("bob@yourdomain.com")
SMTPSchedulingOptions.Port = 25
SMTPSchedulingOptions.SenderAddress = "Robert@Nowhere.com"
SMTPSchedulingOptions.ServerName = "SMTPServer"
SMTPSchedulingOptions.Message = "The most current sales report. Rob."
SMTPSchedulingOptions.SMTPAuthentication = 0
SMTPSchedulingOptions.SMTPUserName = ""
SMTPSchedulingOptions.SMTPPassword = ""
SMTPSchedulingOptions.EnableAttachments = True
ScheduleInfo.AlertDestination.SetFromPlugin (SMTP)
'Schedule the report.
IStore.Schedule (Result)
End Sub
Sorry about the weird line spacing, it's doesn't copy that over well for some reason.
Y