Dear All,
Im doing an application in which i have created a crystal report from database. I was able to send the report as attachment in email. But the extension is rpt. How can i convert the report to pdf and send the pdf as attachment. I have tried so many ways but everything is failing. here is my code.
using system.web.mail; private bool SendWebMail(string strTo, string subj, string cont, string cc, string bcc, string strfrom) { // generating crystal reports DataTable dre = bus.generatereport(); rd.Load(Server.MapPath(Request.ApplicationPath) + "/user/MonthlyReport.rpt"); rd.SetDataSource(dre); bool flg = false; MailMessage msg = new MailMessage(); msg.Body = cont; msg.From = strfrom; msg.To = strTo; msg.Subject = subj; msg.Cc = cc; msg.Bcc = bcc; msg.Attachments.Add(new MailAttachment(Server.MapPath(Request.ApplicationPath) + "/user/MonthlyReport.rpt")); msg.BodyFormat = MailFormat.Html; try { //SmtpMail.SmtpServer = "175.143.44.165"; SmtpMail.SmtpServer = "192.168.1.4"; // change the ip address to this when hosting in server SmtpMail.Send(msg); flg = true; } catch (Exception) { flg = false; } return flg; }
How can i send pdf instead of rpt.
Thanks in advance,
Agaile