My current application send an .rtf in an attachement. I wish to send pdf instead of that. Where in my code I should modify the same?
Below is my code
RichTextBox rtbReport = new RichTextBox(); //Creating instance of Richtextbox
AppResult objResult = null; //Object of Class
frmExaminationReport objReport = new frmExaminationReport(examinationID, ProviderID, PatientID, examType); // Object of Class
AddressBookDataTable dtAddress = null;
rtbReport.Rtf = objReport.RTF; // Entire Result is assigned to Richtext box class
frmMail objMail = new frmMail(); //Object of Mail Class
string directoryPath = Application.StartupPath + "\\Temp"; //Creating directory
string tempFileName = "Report_" + DateTime.Today.Year.ToString() + DateTime.Today.Month.T开发者_如何转开发oString() + ".rtf"; //Generating Name
FileStream fsReport = new FileStream(directoryPath + "\\" + tempFileName, FileMode.CreateNew); // FileStream
fsReport.Write(ASCIIEncoding.ASCII.GetBytes(rtbReport.Rtf), 0, rtbReport.Rtf.Length); // Writing
fsReport.Flush();
fsReport.Close();
fsReport.Dispose();
objMail.MailSubject = examType + " Report"; //Mail Subject
Let me know if any inputs needed
Your code is incomplete or does not make sense (only for me?). Here is a simple tutorial to send email with attachment.
If you are generating PDF documents using your code then checkout some related questions in SO.
I don't think you can simply change .rtf to .pdf to generate PDF documents.
string tempFileName = examType + "Report_" + DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString() + ".rtf";
精彩评论