cancel
Showing results for 
Search instead for 
Did you mean: 

Mail

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

Former Member
0 Kudos

Hi,

Please explain the ConfigurationSettings.AppSettings lines in your code.

Regards

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Kuldeep,

Actually It Gets the AppSettingsSection data for the current application's default configuration.

I have made some changes to my AppConfig file. So that I can read and use it anywhere I want.

After changes my AppConfig file looks like this:

<?xml version="1.0"?>

<configuration>

<appSettings>

    <add key="sqlserver" value="PC-37"/>

    <add key="sqluname" value="sa"/>

    <add key="sqlpass" value="admin@password"/>

    <add key="dbname" value="DBTEST"/>

  </appSettings>

<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>

Hope you got what am I trying to make you understand.

Thanks & Regards

Ankit Chauhan

Former Member
0 Kudos

Hi,

Thanks

Answers (1)

Answers (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

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