Monday, March 21, 2016

Outlook Attachment & Send in NAV 2016 Using Dotnet Variables

Hi All,
     Today I'm going to describe how you can do the bellow requirements using NAV 2016.
1. Open Outlook Application.
2. Attach file.
3. Send attachment.

Solution:

      To achieve all requirements follow the given steps:

Step-1: Create a codeunit in my case ID 90001, Name "Outlook Attachment & Send".

Step-2: Open the C/AL Globals and Declare theses Variables [See the Bellow Screenshot].



Name DataType    Subtype  Length
olapp DotNet Microsoft.Office.Interop.Outlook.ApplicationClass.'Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

olMail DotNet Microsoft.Office.Interop.Outlook.MailItem.'Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

OlItemType DotNet Microsoft.Office.Interop.Outlook.OlItemType.'Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

olAttachType DotNet Microsoft.Office.Interop.Outlook.OlAttachmentType.'Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

BodyFormats DotNet Microsoft.Office.Interop.Outlook.OlBodyFormat.'Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

Note: Sets the each DotNet Variables "RunOnClient" property "Yes" [See the Bellow Screenshot].

CU-Outlook Attachment & Send Variables Property


Step-3: Write the C/AL Code on "OnRun" trigger [See the Bellow Screenshot].

CU-Outlook Attachment & Send


Step-4: Save & Run this Codeunit.

Result: Opened Outlook And Sent Email with Attachments.

Note: If  this "olMail.Send;" is commented then only display the outlook application with attachment.


Thanks & Best Wishes
Binesh Singh
(MCP, MS, MCTS)

Popular Posts