Read a .msg file in NAV 2015

Baptiste2Baptiste2 Member Posts: 6
edited 2015-03-31 in NAV Three Tier
Hello everyone,

I want to extract the sender and receiver address from a .msg file from Nav. I'm working on a NAV 2015 server.
I can't read it from outlook.
I was looking for a DotNet or an Automation to do that, but I only found explanations to send an email.

Does anyone already faced that problem before and have some clue to give me.

Thank you.

Baptiste

Comments

  • wakestarwakestar Member Posts: 207
    for NAV you'll probably have to write your own DotNet Interop Assembly

    a good point to start is always....

    http://bit.ly/1NyzbL9
  • mdPartnerNLmdPartnerNL Member Posts: 802
    Look for Rebex.com
  • Baptiste2Baptiste2 Member Posts: 6
    Yes I thought about create my own add-in, but I hoped there would be already something to start with.

    Thank you anyway.
  • ftorneroftornero Member Posts: 522
    With this DLL to wrap the call to CreatItemFromTemplate due to its second parameter (Type.Missing) that I can't make it works in NAV.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Office.Interop.Outlook;
    
    namespace MailItemClass
    {
        public class Class1
        {
            public static MailItem getMailItem(string fichero)
            {
                Application outl = new Application();
                MailItem item = (MailItem) outl.CreateItemFromTemplate(fichero, Type.Missing);
                return (item);
            }
        }
    }
    

    An this codeunit with a example, you can read .msg files
    OBJECT Codeunit 50113 Test read .msg
    {
      OBJECT-PROPERTIES
      {
        Date=31/03/15;
        Time=12:28:57;
        Modified=Yes;
        Version List=PRUEBA;
      }
      PROPERTIES
      {
        OnRun=BEGIN
                MailItem2 := MailItem2.Class1;
    
                msgFile := 'C:\PASO\prueba.msg';
    
                MailItem := MailItem2.getMailItem(msgFile);
    
                MESSAGE('Send by: %1\\To: %2', MailItem.SenderEmailAddress, MailItem."To");
              END;
    
      }
      CODE
      {
        VAR
          MailItem2@1000000000 : DotNet "'MailItemClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.MailItemClass.Class1" RUNONCLIENT;
          MailItem@1000000001 : DotNet "'Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.MailItem" RUNONCLIENT;
          msgFile@1000000002 : Text;
    
        BEGIN
        END.
      }
    }
    

    I can post a link to the DLL if you want it.

    Regards.
  • Baptiste2Baptiste2 Member Posts: 6
    Thank you for your sample. :D
    I want to add some modifications, but it will give me a good base to start with.
  • Baptiste2Baptiste2 Member Posts: 6
    Thank you for your sample. :D
    I want to add some modifications, but it will give me a good base to start with.
Sign In or Register to comment.