Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Mail

Dear experts,

I am using this solution in the thread:

Crystal Report

I have saved a Crystal Report into PDF. Now I want to send this PDF into mail.

How to know the location where it has been saved. And how to send it in mail.?

Please reply me.

Regards

replied

Hi,

Here is a sample how to do it. You can change it accordingly:

PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();

CrDiskFileDestinationOptions.DiskFileName = System.Windows.Forms.Application.StartupPath + @"\Mail" + "25" + ".pdf";

          

CrExportOptions = cryRpt.ExportOptions;

{

                CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;

                CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

                CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;

                CrExportOptions.FormatOptions = CrFormatTypeOptions;

}

cryRpt.Export();

MailMessage message = new MailMessage();

SmtpClient smtp = new SmtpClient();

message.From = new MailAddress(ConfigurationSettings.AppSettings["emailfrom"]);

message.To.Add(new MailAddress("To"));

System.Net.Mail.Attachment att = new System.Net.Mail.Attachment(System.Windows.Forms.Application.StartupPath + @"\Mail" + "25" + ".pdf");

message.Attachments.Add(att);

The bold lines show you how to get that file that is saved as PDF.

Hope it helps.

Thanks & Regards

Ankit Chauhan

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question