Emailing Invoice

Hi, What is the best way to email an Invoice? The problem is that I won’t to let it send as an attachment but it has to be embedded in to the email itself. I tried a couple of solutions: One is to save the invoice as an html file by using ‘Report.saveashtml’ in codeunit 82: CASE ReportUsage OF ReportSelection.Usage::“S.Invoice”: BEGIN //>>MAS IF SalesHeader.EmailInvoice THEN BEGIN REPORT.SAVEASHTML(ReportSelection.“Report ID”,‘C:\temp\EmailInvoice.htm’,FALSE,SalesInvHeader); Mail.NewMessage(‘roelof@masi.com’,’’,‘Testing Invoice’,’’, ‘C:\temp\EmailInvoice.htm’,FALSE); END; When I use this, I got an error that ‘Salesheader number ## is not excisting’. An other option would be to use CodeUnit Mail and all this OCX stuff to send the Invoice line by line, but then I’m dealing with the layout and stuff like that. Is there a better way to do it? Who can help me out? Thanks, Roelof.

Hi, I think you can send HTML file from Navision only as attachment. You need to create OCX that copy HTML file to the mail body. I think it is not very difficult. I also would like to have such OCX. Valentin Gvozdev BMI Inc.

Hi Roelof, First, I think you should take a look at the topic "Mailbody > 250 ? " in this forum which deals with a problem you will encounter when you try to include the contents of the invoice to the e-mail body. For sending the html-file as bodytext anyway I have the following idea: Use Automation to start WinWord. Open the just created html-file in WinWord and use WinWord’s ActiveDocument.SendMail - method to send the file. Marcus Marcus Fabian phone: +41 79 4397872 m.fabian@thenet.ch

I’d agree with Marcus, please look at the "Mailbody > 250 ? " topic. The solution which I developed was where sales orders & shipments needed to be emailed daily to the UK and imported into a database. I used the Mail codeunit (397), and just attached a text file which was composed in a function I created called CreateFile. Fairly simple solution but quick & easy to develop.

The “Sales header number ### does not exist” error msg…are you FINDing a record first ? CASE ReportUsage OF ReportSelection.Usage::“S.Invoice”: BEGIN //>>MAS IF SalesInvHeader.FIND( ‘-’ ) THEN; IF SalesInvHeader.EmailInvoice THEN BEGIN REPORT.SAVEASHTML(ReportSelection.“Report ID”,‘C:\temp\EmailInvoice.htm’,FALSE,SalesInvHeader); Mail.NewMessage(‘roelof@masi.com’,’’,‘Testing Invoice’,’’, ‘C:\temp\EmailInvoice.htm’,FALSE); END; END;

Thanks.