none
Outlook Addin doesn't render HTML forms using VSTO but using C++ API does RRS feed

  • Question

  • I am rewriting C++ Outlook Addin application to it full .NET representation using VSTO (Outlook 2007/2010).

    One of the features to rewrite is html forms rendering. User can select checkbox, provide input, select option etc. in compose mail mode (before sending). But when I put any input markup to HTMLBody property it isn't rendered as exptected. Instead only something like http://postimage.org/image/jk9swfr2t/ is rendered. I spent a very long time to search for a solution but it always ultimately turned out to be impossible due to Word based Outlook HTML render engine.

    Our C++ addin code repository is extremely large and is legacy - I am not a c++ developer and don't know to much about COM and c++ outlook coresponding APIs, the target is to rewrite according to existing functionalities, there is simply no time and no resources to analize legacy code.

    But the most interesting to me is that c++ version of software render everything: inputs, checkbox, select option, just everythink!. So I guessed it is possible and started looking for a workarround or any kind of hack.

    I analized the old c++ addin using OutlookSpy tool and it turned out that it doesn't fill HTMLBody. I had to wade through a partial legacy code and found that it set PR_HTML MAPI property. Unfortunately I found also that this property is not available in vsto so I can't check if it helps.

    So my questions are:

    Everything must be done programmatically so inserting using Outlook UI or exporting to Outlook from IE doesn't count. Also we can't use commercial third party tools like Redemption or Add-in Express.

    Many thanks in advance!

    Wednesday, November 28, 2012 5:16 PM

Answers

  • if it works using IMessage interface in c++ code then you can also invoke it from c# code using PInvoke and COM functionality. Simply define IMessage, IMAPIProp com interfaces in c# code and import functions like HrSetOneProp to do it. I am suprised that it works nontheless using MAPI and omitting OOM altoegether, i thought that html form rendering was disabled at the level or rendering engine, not depending at how you set that data for mail.
    Wednesday, November 28, 2012 7:47 PM
  • I'd try to avoid any use of the Extended MAPI HrGetOneProp from managed code, as you'd need to instantitate a MAPI session and make sure it's using the same session as Outlook is using. The differences in memory management and other things are why MS doesn't support use of MAPI from managed code, and I think a whole can of worms would be opened leading to all sorts of operational problems down the line.
     
    PR_HTML is a binary array of bytes, which is actually the same property on the item as HTMLBody. The object model just renders it as a string property for HTMLBody as opposed to the PT_BNARY property it is under the hood.
     
    The PropertyAccessor object wouldn't help as it doesn't support use with PR_HTML.
     
    If working with PR_HTML is the only solution you can use I'd recommend wrapping the working C++ code into an unmanaged DLL and calling that using PInvokes from the managed code. That's more or less what Dmitry does with Redemption, which is an unmanaged Delphi/Pascal COM DLL wrapper for Extended MAPI functionality.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "DamianD" <=?utf-8?B?RGFtaWFuRA==?=> wrote in message news:7a8644a2-554d-40b0-8eef-bc85083dbae2...
    if it works using IMessage interface in c++ code then you can also invoke it from c# code using PInvoke and COM functionality. Simply define IMessage, IMAPIProp com interfaces in c# code and import functions like HrSetOneProp to do it. I am suprised that it works nontheless using MAPI and omitting OOM altoegether, i thought that html form rendering was disabled at the level or rendering engine, not depending at how you set that data for mail.

    Ken Slovak MVP - Outlook
    Thursday, November 29, 2012 6:57 PM

All replies

  • if it works using IMessage interface in c++ code then you can also invoke it from c# code using PInvoke and COM functionality. Simply define IMessage, IMAPIProp com interfaces in c# code and import functions like HrSetOneProp to do it. I am suprised that it works nontheless using MAPI and omitting OOM altoegether, i thought that html form rendering was disabled at the level or rendering engine, not depending at how you set that data for mail.
    Wednesday, November 28, 2012 7:47 PM
  • I'd try to avoid any use of the Extended MAPI HrGetOneProp from managed code, as you'd need to instantitate a MAPI session and make sure it's using the same session as Outlook is using. The differences in memory management and other things are why MS doesn't support use of MAPI from managed code, and I think a whole can of worms would be opened leading to all sorts of operational problems down the line.
     
    PR_HTML is a binary array of bytes, which is actually the same property on the item as HTMLBody. The object model just renders it as a string property for HTMLBody as opposed to the PT_BNARY property it is under the hood.
     
    The PropertyAccessor object wouldn't help as it doesn't support use with PR_HTML.
     
    If working with PR_HTML is the only solution you can use I'd recommend wrapping the working C++ code into an unmanaged DLL and calling that using PInvokes from the managed code. That's more or less what Dmitry does with Redemption, which is an unmanaged Delphi/Pascal COM DLL wrapper for Extended MAPI functionality.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "DamianD" <=?utf-8?B?RGFtaWFuRA==?=> wrote in message news:7a8644a2-554d-40b0-8eef-bc85083dbae2...
    if it works using IMessage interface in c++ code then you can also invoke it from c# code using PInvoke and COM functionality. Simply define IMessage, IMAPIProp com interfaces in c# code and import functions like HrSetOneProp to do it. I am suprised that it works nontheless using MAPI and omitting OOM altoegether, i thought that html form rendering was disabled at the level or rendering engine, not depending at how you set that data for mail.

    Ken Slovak MVP - Outlook
    Thursday, November 29, 2012 6:57 PM