Invoice by Mail from N4

Rainer
Member Posts: 103
On Codeunit 82, I call another Codeunit with this code. The problem is that, it is the next-latest invoice which is attatched the mail.
This is only test, a real solution needs more code. BUT all is working exept the "attatch-problem".
..:
OnRun(VAR Rec : Record "Sales Invoice Header")
// Print to PDF file and generate the right invoice !!
REPORT.RUN(50206,FALSE,FALSE,Rec);
AttatchedFileName := 'c:\faktura.pdf';
Text_Subject := 'Faktura no. '+Rec."No.";
Text_Body := 'Due date : '+FORMAT(Rec."Due Date");
// NewMessage('info@rainerbay.dk','info@rainerbay.dk',Text_Subject,Text_Body,AttatchedFileName,TRUE);
::.
// Where "NewMessage" is a procedure in the Codeunit.
This is only test, a real solution needs more code. BUT all is working exept the "attatch-problem".
..:
OnRun(VAR Rec : Record "Sales Invoice Header")
// Print to PDF file and generate the right invoice !!
REPORT.RUN(50206,FALSE,FALSE,Rec);
AttatchedFileName := 'c:\faktura.pdf';
Text_Subject := 'Faktura no. '+Rec."No.";
Text_Body := 'Due date : '+FORMAT(Rec."Due Date");
// NewMessage('info@rainerbay.dk','info@rainerbay.dk',Text_Subject,Text_Body,AttatchedFileName,TRUE);
::.
// Where "NewMessage" is a procedure in the Codeunit.
0
Comments
-
How are you creating the pdf file - is it via pdf995???
Try doing this before creating the file:
if exists(filename) then
erase(filename)
the other thing to watch for is that you give the OS time to save the attachment - try doing a repeat until with a sleep command (and maybe a yield to give the OS chance to do its stuff) until the file exists.0 -
Hi Rainer,
the problem is the REPORT.RUN
If you do not use RUNMODAL the code will continue to run while the report is generated. So when the "New Message" code is run the report is not finished yet.
If you use REPORT.RUNMODAL the system will wait for a reponse to the print before it continues.
br
Anders0 -
It is pdf995 I use, and I solved the problem. It is exactly becaurse the PDF file is not "sent" to its destination yet, while the mail is generated.
I guess its while I still use the free pdf995 with PopUps.. I put in a little "wait" in the code..and wupty it works.
Thanks alot..0 -
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions