Hi
I have been playing around with the Email routines in NAV, specifically the Mail codeunit 397 and trying to send multiple attachments by Outlook.
However, what seems to be a simple modification is being anything but!
I have added a function which is based on the standard CreateAndSendMessage function, but accepts an Array of AttachFilenames. This then calls the standard AttachFile function in a loop. See below.
LOCAL CreateAndSendMessageMultipleAttachments(ToAddresses : Text;CcAddresses : Text;BccAddresses : Text;Subject : Text;Body : Text;AttachFilenames : ARRAY [4] OF Text;ShowNewMailDialogOnSend : Boolean;RunModal : Boolean) : Boolean
// -001
Initialize;
CreateMessage(ToAddresses,CcAddresses,BccAddresses,Subject,Body,ShowNewMailDialogOnSend,RunModal);
FOR Loop := 1 TO 4 DO
IF AttachFilenames[Loop] <> '' THEN
AttachFile(AttachFilenames[Loop]);
EXIT(Send);
// +001
AttachFile(Filename : Text)
Initialize;
IF Filename <> '' THEN
OutlookMessageHelper.AttachmentFileNames.Add(Filename);
However when attaching the second file NAV or Outlook seem to get it's knickers in a twist and comes up with the following error.
Microsoft Outlook is not available.
Do you want to continue to edit the e-mail?
I haven't been able to resolve this so thought I'd see if anyone had any clues. We are using NAV 2016 and Outlook 2013.
I have this working via SMTP but also need to have it working via Outlook.
Thanks in advance.
Chris
"When you eliminate the impossible, whatever remains, however improbable, must be the truth" - Sherlock Holmes
"God and developers are in a constant battle. Developments to make their applications more idiot-proof, and God to produce bigger idiots!"
Answers
"God and developers are in a constant battle. Developments to make their applications more idiot-proof, and God to produce bigger idiots!"
The filename must be a reference to a client file.
Tino Ruijs
Microsoft Dynamics NAV specialist