代码之家  ›  专栏  ›  技术社区  ›  xorpower

以电子邮件附件形式发送pdf

  •  0
  • xorpower  · 技术社区  · 14 年前

    我当前的应用程序在附件中发送一个.rtf。我想发送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
    

    如果需要任何输入,请告诉我

    1 回复  |  直到 14 年前
        1
  •  2
  •   Community leo1    7 年前

    您的代码不完整或没有意义(仅对我而言?). Here is a simple tutorial 发送带有附件的电子邮件。

    如果使用代码生成PDF文档,请签出一些 related questions 所以。

    我不认为您可以简单地将.rtf更改为.pdf来生成pdf文档。

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