Create PDF + Send Mail (with template) : Navision 4.0

Navision 4.0 - create PDF documents and send mail

Hi, i need to print invoices massively in pdf and send it automatically attached to every client, using a default email template (with company logo, company informations, etc…) I need to send mails immediatly or in batch mode.

With the 4.0 release we can not use the direct send SMTO codeunbit present in release 5.0.

What are the best solutions to create the PDF and send them automatically via email with this release of Navision?
You should use external programs?

Thanks for the support.




A few other links:

Hope this help!

an add-on is nice, but if you are going to post that, then please give a basic price range.

Ask the sellers for pricing.

Hi Roberto,

to send email with pdf i use this solution in NAV 4.0:

  • Create pdf attachment using bullzip

  • Send message with:

  1. Standard Codeunit Navision 397 “Mail” → it use ‘Navision Attain Hash 1.0’.BSTRConverter + ‘NS Outlook Synchronization Handler’.OAttachments objects and it needs Outlook.

  2. CDonts Windows or Csys Windows. Using the same codeunit 397 with a custom function. It doesn’t need Outlook.

Problem: you can’t manage the template.

This is the the codeunit that i created to call 397 functions

filename := ‘C:\temp\FAT02’;
testfile := EXISTS(filename);

IF testfile THEN BEGIN

EmailBody[1] := ’ Cordiali Saluti ';
EmailBody[2] := ’ Marco Antonioli ';

cr := 10;
lf := 13;

//OPTION 1 - Navision Outlook DLL
BodyText := EmailBody[1] + FORMAT(cr) + FORMAT(lf) + EmailBody[2];
mymail.NewMessage(, ‘Invoice’,BodyText,filename,FALSE);

//OPTION 2 - Microsoft CDO DLL
mymail.SendEmailCDO(filename, “”, ‘Fatturazione Elettronica’, ‘’, ‘’, ‘’);

This is my function on Codeunit 397

//Send email using cdonts+ActiveX

flds := objEmailConf.Fields;

//Smtp Server
fld := flds.Item(‘’);
fld.Value(‘’); //smtpserver

//stmp server port
fld := flds.Item(‘’);

fld := flds.Item(‘’) ;

fld := flds.Item(‘’) ;

fld := flds.Item(‘’) ;

fld := flds.Item(‘’);

IF ISCLEAR(objEmail) THEN CREATE(objEmail);

//Email Body

objEmail.Configuration := objEmailConf;
objEmail.From := parMailFrom;
objEmail.“To” := parMailTo;
objEmail.Subject := 'Invio documento PDF : ’ + parDocNo;
objEmail.TextBody := 'Invio documento PDF : ’ + parDocNo;

parFileName := parFileName;


Grazie Marco, alla fine ho utilizzato una tecnologia mista partendo dal tuo spunto.

Ho testato quello che mi hai segnalato e ho visto che:

  • Soluzione Outlook: obbliga ad avere Outlook o almeno la type library Outlook installata; si pianta se mando troppe mail (direi che la 50 hanno risolto il problema ma a me serve sulla 4)

  • cdonts : funziona ma obsoleta (vecchia gestione componente no template allegabile)

come ho risolto:

PDF → “Bullzip Pdf free” per creare i pdf in automatico da tabella parametri, un report che lancia generazione pdf per altri report schedulabile; dinamicamente imposta percorsi salvataggio e nome documento, funziona bene,

MAIL → creato una dll in C# per .NET che si appoggia sulle classe Mail del Frameworl (try catch etc per rollback errori) che viene chiamata da nav come automation ; permette di gestire tutte le funzionalità complesse compreso template, immagini etc…

A Gooogle translate of previous post:

Thanks Mark, I eventually used a mixed technology, starting from your cue.

I tested what I’ve reported and I saw that:

- Solution for Outlook requires Outlook or at least to have the Outlook type library installed, the plant if you send too much email (I would say that 50 have solved the problem but I need about 4)

- CDONTS: working but obsolete (old management component template no attachments)

how I solved:

PDF → “Bullzip Pdf free” to create PDFs automatically from table parameters, launches a report that generate PDF reports for other scheduling; dynamically set routes and save file name, it works well,

MAIL → created a dll in C #. NET class that relies on the Frameworl Mail (try catch errors etc for rollback) is called NAV as automation, enables you to manage all the complex features including templates, images, etc. …

Roberto Stefanetti

Roberto - please use English in English forum, EVEN if you communicate with your fellow Italian. If you prefer to communicate in Italian, that for here exist International forums (including Italian).

Ja es te sākšu rakstīt latviski, neviens neko nesapratīs. what means - If I’ll start writing here in Latvian, nobody will understand.