OnAfterGetRecord=BEGIN Cust.GET("Sell-to Customer No.");; Cust.TESTFIELD("Invoice E-Mail"); SendPDFReport.SetParams(ReportNo, Cust."Invoice E-Mail", Text001); SendPDFReport.SetSalesInv("Sales Invoice Header"); SendPDFReport.RUN; END;
OBJECT Codeunit 50002 Send PDF Report { OBJECT-PROPERTIES { Date=24/11/09; Time=09:15:39; Modified=Yes; Version List=CH01201; } PROPERTIES { OnRun=BEGIN GLSetup.GET; GLSetup.TESTFIELD("PDF Creator Driver Name"); PDFFileName := STRSUBSTNO(SubjectTxt, SalesInvHeader."No.") PDFDirectory := TEMPORARYPATH; IF ISCLEAR(PDFCreator) THEN CREATE(PDFCreator); IF ISCLEAR(PDFCreatorError) THEN CREATE(PDFCreatorError); PDFCreatorError := PDFCreator.cError; IF NOT PDFCreator.cStart('/NoProcessingAtStartup', TRUE) THEN ERROR(Text002 + FORMAT(PDFCreatorError.Number) + ']: ' + PDFCreatorError.Description); PDFCreatorOption := PDFCreator.cOptions; PDFCreatorOption.UseAutosave := 1; PDFCreatorOption.UseAutosaveDirectory := 1; PDFCreatorOption.AutosaveDirectory := PDFDirectory; PDFCreatorOption.AutosaveFormat := 0; PDFCreatorOption.AutosaveFilename := PDFFileName; PDFCreator.cOptions := PDFCreatorOption; PDFCreator.cClearCache(); DefaultPrinter := PDFCreator.cDefaultPrinter; PDFCreator.cDefaultPrinter := GLSetup."PDF Creator Driver Name"; PDFCreator.cPrinterStop := FALSE; REPORT.RUNMODAL(ReportNo, FALSE, TRUE, SalesInvHeader) //PDFCreator.cIsConverted := FALSE; REPEAT UNTIL PDFCreator.cIsConverted; Mail.NewMessage(EMailAddress, '', STRSUBSTNO(SubjectTxt, SalesInvHeader."No."), '', PDFDirectory + PDFFileName + '.pdf', TRUE) IF EXISTS(PDFDirectory + PDFFileName + '.pdf') THEN IF ERASE(PDFDirectory + PDFFileName + '.pdf') THEN; END; } CODE { VAR GLSetup@1000000020 : Record 98; SalesInvHeader@1000000011 : Record 112; PDFCreator@1000000002 : Automation "{1CE9DC08-9FBC-45C6-8A7C-4FE1E208A613} 6.1:{FBAAB693-CD00-42DE-ADB1-C5E5CA03700D}:'PDFCreator'.clsPDFCreator" WITHEVENTS; PDFCreatorOption@1000000001 : Automation "{1CE9DC08-9FBC-45C6-8A7C-4FE1E208A613} 6.1:{FCC886F6-E0DF-4302-8BE4-F8A8D9CB881C}:'PDFCreator'.clsPDFCreatorOptions"; PDFCreatorError@1000000000 : Automation "{1CE9DC08-9FBC-45C6-8A7C-4FE1E208A613} 6.1:{84D26557-2990-4B3E-A99F-C4DC1CB6C225}:'PDFCreator'.clsPDFCreatorError"; Text002@1000000005 : TextConst 'ENG=Startup Error['; Text003@1000000004 : TextConst 'ENG=Error['; Mail@1000000014 : Codeunit 397; PDFDirectory@1000000009 : Text[1000]; PDFFileName@1000000008 : Text[250]; DefaultPrinter@1000000007 : Text[250]; EMailAddress@1000000015 : Text[50]; SubjectTxt@1000000006 : Text[30]; ReportNo@1000000003 : Integer; PROCEDURE SetParams@1000000000(RepNo@1000000001 : Integer;EMail@1000000002 : Text[50];Subject@1000000003 : Text[30]); BEGIN ReportNo := RepNo; EMailAddress := EMail; SubjectTxt := Subject; END; PROCEDURE SetSalesInv@1000000001(VAR SalesInvHdr@1000000000 : Record 112); BEGIN SalesInvHeader.RESET; SalesInvHeader.SETRANGE("No.", SalesInvHdr."No."); SalesInvHeader.FINDFIRST; END; EVENT PDFCreator@1000000002::eReady@1(); BEGIN PDFCreator.cPrinterStop := TRUE; PDFCreator.cDefaultPrinter := DefaultPrinter; PDFCreator.cClose(); END; EVENT PDFCreator@1000000002::eError@2(); BEGIN ERROR(Text003 + FORMAT(PDFCreatorError.Number) + ']: ' + PDFCreatorError.Description); END; BEGIN END. } }
Comments
maybe this will help
Thanks very much for your prompt response. I tried this but it did not help. But what is interesting I checked the same objects on Win XP (before I've run it on Vista) and on XP it works fine. Maybe the problem lies here.
Cheers,
Marcin