How do you save an e-mail attachment as PDF not HTML?

gadzilla1
gadzilla1 Member Posts: 316
Hello all,

I'm wondering if anyone out there has modified Report 14000901 - Sales E-Mail to save the attachment as a PDF as opposed to HTML?

There is a section of code in Report 14000901 that I've been playing with but have had limited success:

SaveReportAsHTML(EMailAttachment."Attachment Report ID",TempFilename);
MailOCX.AddAttachment(TempFilename);

I've also installed PDFCreator.

If anyone has been able to accomplish this I'd greatly appreciate any help.

Thank you very much - gad1

Comments

  • kriki
    kriki Member, Moderator Posts: 9,121
    The PDFCreator should have installed a virtual printer. Print to that printer and PDFCreator will create a pdf-file.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • gadzilla1
    gadzilla1 Member Posts: 316
    Thanks - but I may be misunderstanding something. I've used the virtual printer for PDFCreator and can print to it...it saves the print out as a PDF.

    I still do not understand how to revise the SaveAsHtml code so the attachment as PDF is made automatically?

    Sorry for the confusion...
  • Savatage
    Savatage Member Posts: 7,142
    It looks like if your PDF is saved in a set place with a set name that you can add it to the email setup as fixed file. It also allows for a report to be attached already see the section:
    // Create and add attachment
    IF ShowStatus THEN
      Window.UPDATE(1,'Attachments');
    EMailAttachmentTmp.DELETEALL;
    EMailAttachment.RESET;
    EMailAttachment.SETRANGE("E-Mail Code",EMailHeader.Code);
    IF EMailAttachment.FIND('-') THEN BEGIN
      EMailSetup.TESTFIELD("E-Mail Buffer Directory");
    
      REPEAT
        CASE EMailAttachment.Type OF
          EMailAttachment.Type::Report: //ALLOWS A REPORT
            BEGIN
              EMailAttachment.TESTFIELD("Attachment Name");
              EMailAttachment.TESTFIELD("Attachment Report ID");
    
              TempFilename := EMailSetup."E-Mail Buffer Directory";
              IF COPYSTR(TempFilename,STRLEN(TempFilename),1) <> '\' THEN
                TempFilename := TempFilename + '\';
              TempFilename := TempFilename + FieldValue.SubstituteAttachment(EMailAttachment);
    
              SaveReportAsHTML(EMailAttachment."Attachment Report ID",TempFilename);
              MailOCX.AddAttachment(TempFilename);
    
              EMailAttachmentTmp := EMailAttachment;
              EMailAttachmentTmp."Use Attachment File Name" := TempFilename;
              EMailAttachmentTmp.INSERT;
            END;
          EMailAttachment.Type::"Fixed File": //ALLOWS A FIXED FILE
            BEGIN
              IF NOT EXISTS(EMailAttachment."Fixed File Name") THEN
                ERROR('Attachment file %1 do not exists.',EMailAttachment."Fixed File Name");
    
              MailOCX.AddAttachment(EMailAttachment."Fixed File Name");
            END;
        END;
      UNTIL EMailAttachment.NEXT = 0;
    END;
    
  • Savatage
    Savatage Member Posts: 7,142
    See I'm thinking the report first creates the PDF file c:\MyFile.Pdf

    in the email setup of the Sales Order or Invoice - whichever your doing to can tell the email to always get the same attachment (Fixed FIle). then have it delete the file once done. Hope that makes sence..