PDF Attachment using CutePDF writer

manjusreemanjusree Member Posts: 79
I am using CutePDF writer to convert reports into PDF files. I need to attach 'Order Confirmation' report in PDF format and send it as email to the customers all in a single button click. I have searched the forum for this and found that PDF attachment is possible.What I want to know is that if I can do it using CutePDF writer. I am not sure whether the
autosave property is available with that. I think this functionality is available with some custom versions only.Any other way to do this?. Has anybody done this using CutePDF?. Any kind of help would be appreciated.

Comments

  • tedcjohnstontedcjohnston Member Posts: 41
    I use Win2PDF, but there are others that will do it. There must be a better way (NAV 2009) but here is how I did it.

    Setup a specific printer by installing Win2PDF with a specific name set to store the PDF file in a user directory with a specific name.

    Set Printer Selections to print the specific report (copy of original report- in my case the Purchase Order) to the specific Win2PDF instance.

    In code on the button check that an e-mail address exists, if not , prompt for it.

    Then call a function in a codeunit I created to handle the PDFs:
    CR := 10;
    LF := 13;
    
    IF ERASE(Text001_FileName) THEN;
    
    PurchaseOrder.RESET;
    PurchaseOrder.SETRECFILTER();
    REPORT.RUNMODAL(50170,FALSE, FALSE, PurchaseOrder);
    
    int := 0;
    REPEAT
      SLEEP(200);
      int += 1;
    UNTIL (int >= 10) OR EXISTS(Text001_FileName);
    
    IF int >= 10 THEN 
      //EXIT(FALSE);
      ERROR('Temp PDF file not created.');
    
    RENAME(Text001_FileName, STRSUBSTNO(Text002_PurchaseOrderFile,PurchaseOrder."No.") );
    
    int := 0;
    REPEAT
      SLEEP(200);
      int += 1;
    UNTIL (int >= 10) OR EXISTS( STRSUBSTNO(Text002_PurchaseOrderFile,PurchaseOrder."No.") );
    
    IF int >= 10 THEN
      ERROR('Temp PDF file not renamed');
    
    SalesPerson.GET(PurchaserCD);
    BodyText := 'For questions regarding this order, please contact:' +
                FORMAT(CR) + FORMAT(LF) +
                FORMAT(CR) + FORMAT(LF) +
                SalesPerson.Name +
                FORMAT(CR) + FORMAT(LF) +
                SalesPerson."Job Title" +
                FORMAT(CR) + FORMAT(LF) +
                SalesPerson."Phone No." +
                FORMAT(CR) + FORMAT(LF) +
                'mailto:' + SalesPerson."E-Mail";
    SalesPerson.GET(PurchaserCD);
    bResults := Mail.NewMessage(SendToAddress,'',STRSUBSTNO('Purchase Order %1',PurchaseOrder."No."),BodyText,
                              STRSUBSTNO(Text002_PurchaseOrderFile,PurchaseOrder."No."),TRUE);
    
    ERASE(STRSUBSTNO(Text002_PurchaseOrderFile,PurchaseOrder."No."));
    

    Hope this helps. As long as CutePDF can be setup to write a specific file name, this setup will work. It works for me as all my users are on 5 Citrix servers, so managing the 5 printer setups is not too difficult. Would be a royal pain if all users had their own PCs where the software needed to be installed and setup.

    Your mileage may vary.
    "There are only two truly infinite things: the universe and stupidity. And I am unsure about the universe." - Albert Einstein
    Corollary- Build and idiot proof system and nature will build a better idiot.
Sign In or Register to comment.