More IConverter For Ya

[This is now documented here: https://msdn2.microsoft.com/en-us/library/bb821176.aspx]

Good news, everyone! We've decided to document some more flags and functions for IConverterSession.

Here are the new constants:

 #define CCSF_USE_TNEF        0x0010 // the converter should embed TNEF in the MIME message
#define CCSF_8BITHEADERS     0x0040 // the converter should allow 8 bit headers
#define CCSF_PLAIN_TEXT_ONLY 0x1000 // the converter should just send plain text

All three of these flags are only valid for MAPI->MIME.

More interesting are the new functions. They take the place of the first and last placeholder functions in the interface. The first, SetAdrBook, allows you to pass a MAPI address book for the converter to use for name resolution. The second, SetCharSet, allows you to tell the converter which character set to use.

Here's a newly updated header. Note that you will need to locate and include mimeole.h for this header to work - there are too many types from that header being used to try and define them all here:

 #pragma once
//Class Identifiers
// {4e3a7680-b77a-11d0-9da5-00c04fd65685} 
DEFINE_GUID(CLSID_IConverterSession, 0x4e3a7680, 0xb77a,
    0x11d0, 0x9d, 0xa5, 0x0, 0xc0, 0x4f, 0xd6, 0x56, 0x85); 

//Interface Identifiers
// {4b401570-b77b-11d0-9da5-00c04fd65685} 
DEFINE_GUID(IID_IConverterSession, 0x4b401570, 0xb77b,
 0x11d0, 0x9d, 0xa5, 0x0, 0xc0, 0x4f, 0xd6, 0x56, 0x85);

// Constants
#define CCSF_SMTP            0x0002 // the converter is being passed an SMTP message
#define CCSF_NOHEADERS       0x0004 // the converter should ignore the headers on the outside message
#define CCSF_USE_TNEF        0x0010 // the converter should embed TNEF in the MIME message
#define CCSF_INCLUDE_BCC     0x0020 // the converter should include Bcc recipients
#define CCSF_8BITHEADERS     0x0040 // the converter should allow 8 bit headers
#define CCSF_USE_RTF         0x0080 // the converter should do HTML->RTF conversion
#define CCSF_PLAIN_TEXT_ONLY 0x1000 // the converter should just send plain text
#define CCSF_NO_MSGID        0x4000 // don't include Message-Id field in outgoing messages

interface IConverterSession : public IUnknown
{
   public:
 virtual HRESULT STDMETHODCALLTYPE SetAdrBook(LPADRBOOK pab);
    virtual HRESULT STDMETHODCALLTYPE SetEncoding(ENCODINGTYPE et);
 virtual HRESULT PlaceHolder1();
 virtual HRESULT STDMETHODCALLTYPE MIMEToMAPI(LPSTREAM pstm,
         LPMESSAGE pmsg,
         LPCSTR pszSrcSrv,
           ULONG ulFlags);
 virtual HRESULT STDMETHODCALLTYPE MAPIToMIMEStm(LPMESSAGE pmsg,
         LPSTREAM pstm,
          ULONG ulFlags);
 virtual HRESULT PlaceHolder2();
 virtual HRESULT PlaceHolder3();
 virtual HRESULT PlaceHolder4();
 virtual HRESULT STDMETHODCALLTYPE SetTextWrapping(BOOL fWrapText,
           ULONG ulWrapWidth);
 virtual HRESULT STDMETHODCALLTYPE SetSaveFormat(MIMESAVETYPE mstSaveFormat);
    virtual HRESULT PlaceHolder5();
 virtual HRESULT STDMETHODCALLTYPE SetCharset(
       BOOL fApply,
        HCHARSET hcharset,
      CSETAPPLYTYPE csetapplytype);
};

Some notes:

  • The LPADRBOOK passed in to SetAdrBook is obviously a MAPI address book. While conversion can normally be done without logging on to a MAPI profile, if SetAdrBook is to be used you will need to log on to a profile to get an address book.
  • HCHARSET is a handle, not a constant. NULL is a valid value. For non-NULL values, you'll need to fetch an HCHARSET using a function like MimeOleGetCodePageCharset. This means you'll either need to link in inetcomm.lib or do the LoadLibrary/GetProcAddress thing.
  • If fApply is false, then the parameters passed in SetCharSet aren't used. You'd do this if you wanted to set a character set for a particular message, then return to the defaults for subsequent messages.
  • In SetAdrBook, pab can be NULL. This will reset the converter to not using an address book.
  • SetAdrBook and SetCharSet always returns S_OK. But you should still check in case we later decide there's a case where they can fail.

I think I documented the new flags correctly - if not, let me know and I'll fix them.