Search code examples
c#exchange-serverfile-format

Programmatically creating a native Outlook Distribution List


If I share a distribution list in Outlook in 'Outlook Format' the result is a .msg file. Double-clicking on this file opens the Distribution List window in Outlook.

I have an app that contains a list of email contacts and my user wants to be able to send this list out as an Outlook Distribution List.

Now, I know I can export it as a .csv file so that the user can import this, but that's not what's required.

So, to the question: does anyone know if it is possible to generate this .msg file in the correct format from a 3rd-party application for use by Outlook?

If it of any import or relevance, the app is an ASP.NET C# WebApplication


Solution

  • You can use Extended MAPI for that (C++ or Delphi only, use OpenIMsgOnIStg, etc.) and set a bunch of named properties. You can also use Redemption (I am its author) and create a distribution list on top of an MSG file using RDOSession.CreateMessageFromMsgFile (assuming Outlook/MAPI system are installed):

      set Session = CreateObject("Redemption.RDOSession")
      set DL = Session.CreateMessageFromMsgFile("c:\temp\TestDL.Msg", "IPM.DistLIst", 1)
      DL.AddMemberEx "Joe The User", "[email protected]", "SMTP"
      DL.Save