formsoutlookoffice-interopmsgoft

Prefilling "Outlook form " programatically on server before user downloads it


I do have an existing Outlook Form, which already has predefined logic, named fields and comboboxes. This form is the standard input for a different apartment, so I am not allowed to change the form in a way that would break their processing.

What I need to do is to prefill some of the fields of the form dynamically on my server side where I have the information available, and provide it as .msg file to the end user. The user could then modify some of the fields, both the ones I prefilled and the others.

My question is, are there any APIs or "find & replace" tricks I could use to prefill properties of the outlook form programmatically on my server? If it helps anything, values.

I have tried a naïve approach for putting $NAME$ in the property value and then doing a simple text replacement, but Outlook could not open the .msg after that - I am assuming there are some checksums or dependencies within the internal data structures.

The preferred platforms are .NET or Java, but other options would be also fine.


Solution

  • Outlook Object Modle can open MSG file using Namespace.OpenSharedItem, but OOM cannot be used from a service (such as IIS).
    You can open and modify MSG file using Extended MAPI (C++ or Delphi only) using OpenIMsgOnIStg etc.
    In case of .Net or Java, you can use Redemption (I am its author) and its RDOSession.GetMessageFromMsgFile method (returns RDOMail object). You can modify the properties using RDOMail.Fields[] and then save the MSG file by calling RDOMail.Save.
    You can look at the existing MAPI properties and their DASL names in OutlookSpy (click OpenIMsgOnIStg button).