0

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.

Tomas Grosup
  • 6,396
  • 3
  • 30
  • 44

1 Answers1

1

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).

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Thank you, the Outlook object model does work. I have read that Outlook automation on the server is not officially supported, but is there something which actively prevents it? It looks superior to the other options, and is something which works out of the box without additional purchases. – Tomas Grosup Oct 24 '17 at 07:55
  • Server is fine, it is a service that is a problem. Outlook will crash or hang. Not a question of if, but when. – Dmitry Streblechenko Oct 24 '17 at 17:00
  • Would it make a difference if the server starts a cmd tool as a new process, and the actual office interop is done from that tool? I have tested that and it works the same way, and I am able to serve file within a second or so. The thing I cannot test on my own are the crash scenarios, thats why I am asking... – Tomas Grosup Oct 25 '17 at 15:51
  • No. The problem is that Outlook can and will display message boxes and attempt to interact with the user in other ways. There won't be a live user to accepts or dismiss the prompts. Once again, no Office app (Outlook included) can be used from a service. Microsoft is very explicit about that. – Dmitry Streblechenko Oct 25 '17 at 17:12