2010-11-23 25 views
0

私の現在のアプリケーションは添付ファイルに.rtfを送信します。私はそれの代わりにpdfを送信したいと思う。 私のコードでは同じものを修正する必要がありますか?以下は電子メールの添付ファイルとしてpdfを送信

私のコードは

 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.ToString() + ".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 

ある任意の入力はあなたのコードが不完全であるか(私だけか?)意味がありません

+0

このPDFをどのように生成しますか? –

+0

@ダリン:RTF形式で生成されるすべてのテキストをPDFで生成する必要があるため、PDFが電子メールの添付ファイルとして送信されます –

+0

PDFファイルを生成するための組み込み.NETはありません。たとえば、iTextSharpのようなサードパーティのライブラリを使用する必要があります。 –

答えて

2

を必要に応じて、私に教えてください。 Here is a simple tutorial添付ファイル付きのメールを送信する

コードを使用してPDF文書を生成する場合は、related questionsをご確認ください。

単純に.rtfを.pdfに変更してPDFドキュメントを生成することはできません。

string tempFileName = examType + "Report_" + DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString() + ".rtf"; 
+0

コメントありがとうございます。書き込まれたコードは、richtextboxのオブジェクトを作成し、RTF形式のデータセットがそのオブジェクトに与えられます。rtf ojectはfilestreamオブジェクトに渡されます。私はpdfを送信する電子メールを認識しています。私はまた、拡張機能の変更が動かないことを知っています... –

関連する問題