on 11-03-2008 11:54 AM
Hi All,
I have implemented the ScheduleToSMTP method for sending my crystal report as an email attachment to the users. This has been done as described in the below link(s):
Now, I would like to know if it is possible to have the report attached in two formats (PDF and Excel) in a single email while emailing it by the above method.
Also, I would like to understand if I can add any additional attachments (an image maybe) to this email that goes out through the CMS.
I am new to the Crystal SDK and will appreciate if the response is a little descriptive.
Thanks in advance for the help!
Regards
Ankit
You aren't able to specify two different formats when scheduling on Business Objects.
XI 3.x has new functionality - Publications - that allow you to do this with Crystal Reports.
Sincerely,
Ted Ueda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any questions concerning BusinessObjects Enterprise should go to:
Expert Forums » Business Objects SDK Application Development » .NET Development - BusinessObjects Enterprise, BusinessObjects Edge, Crystal Reports Server
The .NET Development - Crystal Reports are for the component SDK - CR.NET.
There's currently no hook to add custom files to attachments.
Sincerely,
Ted Ueda
Thanks to Ted and Ludek! It seems what I have been trying to do is not feasible in the current version of Crystal Reports. I will have to look for some workarounds to my problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure if the below approach will work for you, but in a nut shell, you'd export the report to disk, then mail the exported report as an attachment. I have done this with a single attachment when I was fooling around with this couple of years ago, not sure if it will work with multiple attachments... Some think to keep in mind too; the reports can get quite large. A report larger then 5 megs is nothing out of the ordinary, so emailing the rpt may be an issue from that perspective. Anyhow, here is the code to attach a file to email:
Visual Basic Example (C## is also provided below)
-
'Add the following namespaces
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.IO
' Code for exporting the report to PDF and
' attaching the exported file to an email.
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As
DiskFileDestinationOptions
Dim ExportPath As String
' Create an instance of the Report
Dim oRpt As New NameOfYourReport()
' Or open a report file
Dim oRpt1 As New ReportDocument()
oRpt1.Load(Request.PhysicalApplicationPath +
"\YourReport.rpt";,
OpenReportMethod.OpenReportByTempCopy)
' Create the directory path if it does not already
' exist
ExportPath = Request.PhysicalApplicationPath +
"Exported\"
If Directory.Exists(ExportPath) = False Then
Directory.CreateDirectory(Request.PhysicalApplicatio
nPath + "Exported\")
End If
Dim fname As String
fname = ExportPath + "Portabledoc.pdf";
' Set the path for the exported report
crDiskFileDestinationOptions = New
DiskFileDestinationOptions()
crDiskFileDestinationOptions.DiskFileName = fname
' Set the options to export the report to PDF format
crExportOptions = oRpt.ExportOptions
With crExportOptions
.DestinationOptions =
crDiskFileDestinationOptions
.ExportDestinationType =
ExportDestinationType.DiskFile
.ExportFormatType =
ExportFormatType.PortableDocFormat
End With
' Export the report
oRpt.Export()
Response.Write("report exported to: " & fname)
' Create a new mail attachment and add the
' exported report
Dim att As New Mail.MailAttachment((fname))
Dim oMsg As New System.Web.Mail.MailMessage()
oMsg.Attachments.Add(att)
' Set the To, From, And subject for the email
oMsg.To = "someonesemail at email.com"; // the system will not let me use real email
oMsg.From = "myemail at mail.com "
oMsg.Subject = "You have been sent a Crystal Report"
' Connect to the server and send the message
' For example this is the Hotmail smtp Server("")
Mail.SmtpMail.SmtpServer =
"lyris01.hosting.innerhost.com";
System.Web.Mail.SmtpMail.Send(oMsg)
Response.Write("<br>")
Response.Write("Message sent to: " &
oMsg.To.ToString)
' Delete the exported report file
File.Delete(fname)
/////////////////////////////////////////////////////////////////////////////////////////////
C# Example
-
// Add the following namespaces
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.IO;
// Code for exporting the report to PDF and
// attaching the exported file to an email
ExportOptions crExportOptions;
DiskFileDestinationOptions
crDiskFileDestinationOptions;
String ExportPath;
// Create an instance of the Report
NameOfYourReport oRpt = new NameOfYourReport();
// Or open a report file
ReportDocument oRpt1 = new ReportDocument();
oRpt1.Load(Request.PhysicalApplicationPath +
"
YourReport.rpt";,
OpenReportMethod.OpenReportByTempCopy);
// Create the directory path if it does not
// already exist
ExportPath = Request.PhysicalApplicationPath +
"Exported
";
if (Directory.Exists(ExportPath) == false)
{
Directory.CreateDirectory(Request.PhysicalApplicat
ionPath + "Exported
");
}
String fname;
fname = ExportPath + "Portabledoc.pdf";;
// Set the path for the exported report
crDiskFileDestinationOptions = new
DiskFileDestinationOptions();
crDiskFileDestinationOptions.DiskFileName = fname;
// Set the options to export the report to PDF
// format
crExportOptions = oRpt.ExportOptions;
crExportOptions.DestinationOptions =
crDiskFileDestinationOptions;
crExportOptions.ExportDestinationType =
ExportDestinationType.DiskFile;
crExportOptions.ExportFormatType =
ExportFormatType.PortableDocFormat;
// Export the report
oRpt.Export();
Response.Write("report exported to: " + fname);
// Create a new mail attachment and add the
// exported report
System.Web.Mail.MailAttachment att = new
System.Web.Mail.MailAttachment((fname));
System.Web.Mail.MailMessage oMsg = new
System.Web.Mail.MailMessage();
oMsg.Attachments.Add(att);
// Set the To, From, And subject for the email
oMsg.To = "someonesemail at email.com";;
oMsg.From = "myemail at email.com ";
oMsg.Subject = "You have been sent a Crystal
Report";
// Connect to the server and send the message
// For example this is the Hotmail smtp Server("")
System.Web.Mail.SmtpMail.SmtpServer =
"lyris01.hosting.innerhost.com";;
System.Web.Mail.SmtpMail.Send(oMsg);
Response.Write("<br>");
Response.Write("Message sent to: " +
oMsg.To.ToString());
// Delete the exported report file
File.Delete(fname);
///////////////////////////////////////////////////////////////////////////////////////
Ludek
Edited by: Ludek Uher on Nov 4, 2008 8:11 AM
Actually, neither Ted, not I were aware that you are using VB 6. I think all along we have been specifying links to .NET... Also, the your post is in the ".NET development" forum.
The BOE SDK was never tested in VB6 and as such we have no way if it works, nor would we ever be able to get help on this from QA or R&D. The SDK is only tested in .NET...
I do not have VB 6 code equivalent to what I sent in my previous post, but if the idea will work for you, I suspect you may get help by googling the idea for VB 6.
Ludek
Please post this query to the Business Objects SDK Application Development forum:
https://www.sdn.sap.com/irj/sdn/businessobjects-sdk-forums
In this way, we keep queries for specific technologies together which should facilitate searching of similar issues in the forums.
Ludek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.