on 06-02-2015 5:55 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.