Skip to Content

Mail

Dear experts,

I am using this solution in the thread:

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Jun 02, 2015 at 05:17 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 02, 2015 at 05:00 AM

    Hi Kuldeep,

    As you are saving this file into this location:

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

    Now what you can do is that:

    using System.Net.Mail and using its Attachment property you can send it easily to any mail id. You can provide the same path in the attachment.

    Hope it helps.

    Thanks & Regards

    Ankit Chauhan

    Add comment
    10|10000 characters needed characters exceeded