Exporting to Email
Exporting a report to an email creates the report as a separate file and attaches it to an email message. This email message is automatically sent out to the recipient. Table 19-5 shows the properties for exporting to email. Each of these properties relates to the typical settings you find when sending an email message.
Table 19-5. MicrosoftMailDestinationOptions Properties.
Property | Description |
---|---|
MailCCList | The list of emails to send a carbon copy to |
MailMessage | The text portion of the email message |
MailSubject | The text subject heading of the email message |
MailToList | The email(s) of those receiving the report |
Password | The password used when logging on to the email account |
UserName | The user name used when logging on to the email account |
Public Sub SetEmailDestination(ByVal MyReport As CrystalDecisions.CrystalReports.Engine.ReportDocument, ByVal MailTo As String, ByVal CCList As String, ByVal Subject As String, ByVal Message As String, ByVal UserName As String, ByVal Password As String)
'Set the destination type to EMail
MyReport.ExportOptions.ExportDestinationType = _
CrystalDecisions.Shared.ExportDestinationType.MicrosoftMail
'Instantiate an Email options object and set its properties
Dim Options As CrystalDecisions.Shared.MicrosoftMailDestinationOptions = _
New CrystalDecisions.Shared.MicrosoftMailDestinationOptions
Options.UserName = UserName
Options.Password = Password
Options.MailSubject = Subject
Options.MailMessage = Message
Options.MailToList = MailTo
Options.MailCCList = CCList
'Assign the options object to the report
MyReport.ExportOptions.DestinationOptions = Options
End Sub
This procedure first sets the report object’s destination type to be MicrosoftMail. Then it creates a new options variable and assigns the parameters to the appropriate properties. The last step assigns the options object to the DestinationOptions property of the report object.