My Linux Stuff - Complete Blog For Linux Articles

My Linux Stuff - Complete Blog For Linux Articles

A Website For Complete Linux OS,Step by Step linux Installtion, Linux Tips and Tricks and Linux Stuff and so on... Connect and sharing here....

TOP 50 ENGINEERING COLLEGES IN INDIA 2014

TOP 50 ENGINEERING COLLEGES IN INDIA 2014

This below survey was taken many form many colleges in India. These Top 50 Engineering Colleges in India have Good Infrastructure, Good Environment, Educations , Staff, Placement , Research Activities and other Facilities are good.

Top 10 Government Engineering Colleges in India

Top 10 Government Engineering Colleges in India

These Government Engineering Colleges in India are really good for all kind of stuff like Education , research , Placement and New Innovation Ideas etc... But Getting seat in these colleges are heavy competition in students .....

Top 10 Colleges In India 2014

Top 10 Colleges In India 2014

Indian Institute Of Technology Delhi,Indian Institute Of Technology Bombay,Indian Institute Of Technology Kanpur,Indian Institute Of Technology Madras,Indian Institute Of Technology Kharagpur,Indian Institute Of Technology Roorkee,University Of Delhi,Indian Institute Of Technology Guwahati,University Of Calcutta,University Of Mumbai, National Institute Of Technology,Trichy.

2014 LATEST SURVEY TOP RANKING ENGINEERING COLLEGES IN INDIA

2014 LATEST SURVEY TOP RANKING ENGINEERING COLLEGES IN INDIA

This below survey was taken many form many colleges in India. These Top 100 Engineering Colleges in India have Good Infrastructure, Good Environment, Educations , Staff, Placement , Research Activities and other Facilities are good. If you want to do Engineering as your dream and try out these colleges

Subscribe Now!

Enter your email address:

Monday, June 20, 2016

Send Crystal Report to PDF in Email Attachment

Export Crystal Report to PDF & send in Email as Attachment in ASP.Net using C# (MVC C#)

Send Crystal Report to PDF in Email Attachment


Name Spaces 

using System.Net.Http.Headers;
using System.IO;
using System.Net.Mail;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Net;
using System.Data;
using System.Configuration;





Method To send Email


 public ActionResult PrintJobOffer()
        {                      
               myReport.FileName = Server.MapPath("~/Report/Permanant.rpt");
                            myReport.Load();
                            myReport.SetParameterValue("FULLNAME", Data.FULLNAME);
                            myReport.SetParameterValue("NATIONALITY", Data.NATIONALITY);
                            myReport.SetParameterValue("PASSPLACEOFISSUE", Data.PASSPLACEOFISSUE);
                           
                            using (MailMessage message = new MailMessage())
                            {
                                string messageto = "amdi@gmail.com"; // to Email Address
                                message.From = new MailAddress("no_reply@med.com");
                                message.To.Add(new MailAddress(messageto));
                                message.CC.Add(new MailAddress("copy@domain.com"));
                                message.Subject = "Job Offer - HR Department";
                                message.Attachments.Add(new Attachment(myReport.ExportToStream(ExportFormatType.PortableDocFormat), "Permanant.pdf")); //Code For Generate Pdf and sending automatically

                                string strtpath = System.Web.HttpContext.Current.Server.MapPath("~");
                                Path.GetFullPath(strtpath).Replace(@"/", @"//");

                                System.Net.Mail.Attachment attachment1;
                                attachment1 = new System.Net.Mail.Attachment(strtpath + "/assets/images/Confidential_Agreement_Form.pdf");
                                attachment1.Name = "Confidential_Agreement_Form.pdf";
                                message.Attachments.Add(attachment1);

                                System.Net.Mail.Attachment attachment2;
                                attachment2 = new System.Net.Mail.Attachment(strtpath + "/assets/images/Prior_of_Arraiving.pdf");
                                attachment2.Name = "Prior_of_Arraiving.pdf";
                                message.Attachments.Add(attachment2);              
                         
                                message.IsBodyHtml = true;
                                message.Body = "Dear Candidate"; // Body Content
                                SmtpClient client = new SmtpClient();
                                client.Host = "10.90.10.10"; // Server Email Ip Address 
                                client.Port = 25; // Port For Email
                                client.Send(message);
For Gmail
NetworkCredential credential = new NetworkCredential();
        credential.UserName = "sender@gmail.com";
        credential.Password = "xxxxx";
        smtp.UseDefaultCredentials = true;
        smtp.Credentials = credential;
        smtp.Port = 587;
        smtp.EnableSsl = true;
        smtp.Send(message);



                            }
                        }

Related Posts Plugin for WordPress, Blogger...