Friday, September 29, 2017

MAPI is not working properly while sending email in NAV

Recently I have worked on a issue related to E-mail, and would like to share the solution which helped me to resolve the issue.

One user is are getting the following error “MAPI is not working properly. One way to get MAPI working is to install Microsoft Exchange” when they try to send the email. This is version NAV 2009 R2, and in this version one way to send a report by email is using, File –> Send –> Report by Email. as show in Fig 1.

When I have searched the web I have found articles/forums where it was suggested to unregister MAPI OCX Dll File and Register it again, I have performed those steps but still it did not help to resolve the issue.


Fig 1.

One thing I did notice on that workstation was even though Outlook 2013 was installed it was never setup/initialized, once I have setup an account on outlook and then try to send the report by Email it opened the Outlook Client with Report body.

So, please make sure there is a default MAPI email client installed and setup when you receive the above error and that resolved the issue in my case.

If you have any other tips or suggestions to resolve this error, please do share them in the comments below.


Friday, September 22, 2017

How to print a remote file from NAV


I have seen couple of times the requirement where we need to print a document from NAV which is not a report, it could be a marketing campaign letter, sales sheets or any other document.

Most of the time we upload these kind of documents on a website/remote site, so if we need print those documents with every invoice or any other statement, below is the function you can use from NAV.

In the below example I just took a random PDF URL from the web and used it for testing.

The key in this function is to download the document from the web using WebClient locally and then use the Process to print the document to the printer.

LOCAL PROCEDURE PrintRemoteFile@1240060002();
       FileURL@1240060000 : Text;
       ProcessStartInfo@1240060001 : DotNet "'System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.ProcessStartInfo";
       Process@1240060002 : DotNet "'System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.Process";
       WebClient@1240060003 : DotNet "'System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.WebClient";
       LocalFileName@1240060004 : Text;
       FileURL := '';
       ProcessStartInfo := ProcessStartInfo.ProcessStartInfo();
       WebClient := WebClient.WebClient();
       LocalFileName := 'C:\Temp\TempFile.pdf';
       ProcessStartInfo.FileName := LocalFileName;
       ProcessStartInfo.Verb := 'Print';
       ProcessStartInfo.CreateNoWindow := FALSE;
       Process := Process.Process;
       Process := Process.Start(ProcessStartInfo);
       MESSAGE('Document Printed');

If you have any other tips or suggestions to resolve this error, please do share them in the comments below.