Emailing in Crystal Reports

G

Guest

I am using windows forms and using Crystal Reports. I have attempted to email using the standard email sample, but get an exception and the erro
public void CreatePDFEmail(string sendto,string subject,string from, string message, string user, string password

// Declare variables and get the export options
PdfRtfWordFormatOptions pdfRtfWordOpts = ExportOptions.CreatePdfRtfWordFormatOptions()
MicrosoftMailDestinationOptions mailOpts
ExportOptions.CreateMicrosoftMailDestinationOptions()

// Set the export format
pdfRtfWordOpts.FirstPageNumber = 0
pdfRtfWordOpts.LastPageNumber = 0
pdfRtfWordOpts.UsePageRange = false
ExportOptions exportOpts = new ExportOptions()
exportOpts.ExportFormatOptions = pdfRtfWordOpts
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat

// Set the mail options
mailOpts.MailCCList = ""
mailOpts.MailMessage = message
mailOpts.MailSubject = subject
mailOpts.MailToList = sendto
mailOpts.Password = password
mailOpts.UserName = user
exportOpts.ExportDestinationOptions = mailOpts

// Export the report
exportOpts.ExportDestinationType = ExportDestinationType.MicrosoftMail
ReportDocument.Export(exportOpts)


The exception trace is as follow
CrystalDecisions.CrystalReports.Engine.InvalidArgumentException: Invalid export options
at CrystalDecisions.CrystalReports.Engine.EngineExceptionUtils.DoThrowException(String message, EngineExceptionErrorID id
at CrystalDecisions.CrystalReports.Engine. .P(String â™ i, EngineExceptionErrorID â™ j
at CrystalDecisions.CrystalReports.Engine.♂.D(
at CrystalDecisions.CrystalReports.Engine.FormatEngine.W(Stream â™ w, MicrosoftMailDestinationOptions â™ x, String â™ y
at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Export(ExportOptions options

Has anybody any idea what may be wrong with this
 
O

Octavio Hernandez

Hi,

Maybe you didn't install the Crystal support for sending output to MsMail, I
believe you have to do a custom installation for that...
I suggest you to try exporting to a temporary file, and then sending that
file as an attachment.

Regards,

Octavio

RobM said:
I am using windows forms and using Crystal Reports. I have attempted to
email using the standard email sample, but get an exception and the error
public void CreatePDFEmail(string sendto,string subject,string from,
string message, string user, string password)
{
// Declare variables and get the export options.
PdfRtfWordFormatOptions pdfRtfWordOpts = ExportOptions.CreatePdfRtfWordFormatOptions();
MicrosoftMailDestinationOptions mailOpts =
ExportOptions.CreateMicrosoftMailDestinationOptions();

// Set the export format.
pdfRtfWordOpts.FirstPageNumber = 0;
pdfRtfWordOpts.LastPageNumber = 0;
pdfRtfWordOpts.UsePageRange = false;
ExportOptions exportOpts = new ExportOptions();
exportOpts.ExportFormatOptions = pdfRtfWordOpts;
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;

// Set the mail options.
mailOpts.MailCCList = "";
mailOpts.MailMessage = message;
mailOpts.MailSubject = subject;
mailOpts.MailToList = sendto;
mailOpts.Password = password;
mailOpts.UserName = user;
exportOpts.ExportDestinationOptions = mailOpts;

// Export the report.
exportOpts.ExportDestinationType = ExportDestinationType.MicrosoftMail;
ReportDocument.Export(exportOpts);
}

The exception trace is as follows
CrystalDecisions.CrystalReports.Engine.InvalidArgumentException: Invalid export options.
at
CrystalDecisions.CrystalReports.Engine.EngineExceptionUtils.DoThrowException
(String message, EngineExceptionErrorID id)
at CrystalDecisions.CrystalReports.Engine. .P(String ?i, EngineExceptionErrorID ?j)
at CrystalDecisions.CrystalReports.Engine.?.D()
at CrystalDecisions.CrystalReports.Engine.FormatEngine.W(Stream ?w,
MicrosoftMailDestinationOptions ?x, String ?y)
CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestCont
ext reqContext)
 
G

Guest

Hi

I have been unable to locate the files for the custom installation. Can you point me in the right direction

I am concerned that the recent security updates will preclude the sending of attachments on my system Windows XP and I am looking for appropriate code to try out the alternative option

Regard
Rob

----- Octavio Hernandez wrote: ----

Hi

Maybe you didn't install the Crystal support for sending output to MsMail,
believe you have to do a custom installation for that..
I suggest you to try exporting to a temporary file, and then sending tha
file as an attachment

Regards

Octavi

RobM said:
I am using windows forms and using Crystal Reports. I have attempted t
email using the standard email sample, but get an exception and the erro
public void CreatePDFEmail(string sendto,string subject,string from
string message, string user, string password
// Declare variables and get the export options
PdfRtfWordFormatOptions pdfRtfWordOpts ExportOptions.CreatePdfRtfWordFormatOptions()
MicrosoftMailDestinationOptions mailOpts
ExportOptions.CreateMicrosoftMailDestinationOptions()
pdfRtfWordOpts.FirstPageNumber = 0
pdfRtfWordOpts.LastPageNumber = 0
pdfRtfWordOpts.UsePageRange = false
ExportOptions exportOpts = new ExportOptions()
exportOpts.ExportFormatOptions = pdfRtfWordOpts
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat
mailOpts.MailCCList = ""
mailOpts.MailMessage = message
mailOpts.MailSubject = subject
mailOpts.MailToList = sendto
mailOpts.Password = password
mailOpts.UserName = user
exportOpts.ExportDestinationOptions = mailOpts
exportOpts.ExportDestinationType = ExportDestinationType.MicrosoftMail
ReportDocument.Export(exportOpts)

CrystalDecisions.CrystalReports.Engine.InvalidArgumentException: Invali export options
a
CrystalDecisions.CrystalReports.Engine.EngineExceptionUtils.DoThrowExceptio
(String message, EngineExceptionErrorID id
at CrystalDecisions.CrystalReports.Engine. .P(String ?i EngineExceptionErrorID ?j
at CrystalDecisions.CrystalReports.Engine.?.D(
at CrystalDecisions.CrystalReports.Engine.FormatEngine.W(Stream ?w
MicrosoftMailDestinationOptions ?x, String ?y
CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestCon
ext reqContext
 
Top