Hi Roberto,
to send email with pdf i use this solution in NAV 4.0:
-
Standard Codeunit Navision 397 “Mail” → it use ‘Navision Attain Hash 1.0’.BSTRConverter + ‘NS Outlook Synchronization Handler’.OAttachments objects and it needs Outlook.
-
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];
CLEAR(mymail);
mymail.NewMessage(to@email.com, ‘Invoice’,BodyText,filename,FALSE);
//OPTION 2 - Microsoft CDO DLL
mymail.SendEmailCDO(filename, “to@email.com”, ‘Fatturazione Elettronica’, ‘’, ‘’, ‘’);
This is my function on Codeunit 397
//Send email using cdonts+ActiveX
IF ISCLEAR(objEmailConf) THEN
CREATE(objEmailConf);
flds := objEmailConf.Fields;
//Smtp Server
fld := flds.Item(‘http://schemas.microsoft.com/cdo/configuration/smtpserver’);
fld.Value(‘mail.server.com’); //smtpserver
//stmp server port
fld := flds.Item(‘http://schemas.microsoft.com/cdo/configuration/smtpserverport’);
fld.Value(‘587’);
fld := flds.Item(‘http://schemas.microsoft.com/cdo/configuration/smtpauthenticate’) ;
fld.Value(‘1’);
//user
fld := flds.Item(‘http://schemas.microsoft.com/cdo/configuration/sendusername’) ;
fld.Value(‘user’);
fld := flds.Item(‘http://schemas.microsoft.com/cdo/configuration/sendpassword’) ;
fld.Value(‘pwd’);
fld := flds.Item(‘http://schemas.microsoft.com/cdo/configuration/sendusing’);
fld.Value(‘2’);
flds.Update();
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;
objEmail.AddAttachment(parFileName);
objEmail.Send;