Setting properties on existing Redemption Recipient objects?

  • Thread starter Thread starter Martynas Kunigelis
  • Start date Start date
M

Martynas Kunigelis

Sometimes messages that my add in sends programmatically get converted to
TNEF (by Exchange?) even if they are created in HTML mode. The reason for
this sometimes seems to be presence of attachments, or copying and pasting
some fairly complex formatted text from, say, Word.

I want to avoid this, and have the messages always sent in MIME text plus
HTML format. As far as I understand, in order to avoid this, one has to set
PR_SEND_INTERNET_ENCODING and PR_SEND_RICH_INFO properties on a recipient to
proper values (I do know the values).

The question is: how to do this (in C++, preferably), given a Redemption
ISafeRecipient object?

I can add new recipients with the properties using
IMessage::ModifyRecipients(), but then in some configurations the message
can't be sent because recipients are missing entry IDs. I am creating the
entry IDs using IAddrBook::CreateOnOff(), but I think it would be much
cleaner to be able to set these properties on existing recipients.

Is there a way?

Thanks in advance,
Martynas
 
You can just loop through all recipients and add the properties using
Message.Recipients.Item(i).Fields - this corresponds to reading all
properties from the recipient table, modifying each row to set/add
PR_SEND_RICH_INFO and calling IMessage::ModifyRecipients().
Also see below a new FAQ to be posted soon.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

I noticed that if I send a message using Outlook UI, it is delivered in
HTML; if I use Redemption, it is in plain text. Any workarounds?

Selecting an encoding programmatically has always been a mystery in Outlook.
Recently, however, things became a bit clearer. You need to set a couple of
extra properties:

set Appt = Application.CreateItem(olMailItem)
set sItem = CreateObject("Redemption.SafeMailItem")
sItem.Item = Appt
sItem.Recipients.Add "(e-mail address removed)"
sItem.Recipients.ResolveAll
sItem.Subject = "test subject"
sItem.Body = "body"

PR_InetMailOverrideFormat = &H59020003
ENCODING_PREFERENCE = &H00020000
BODY_ENCODING_TEXT_AND_HTML = &H00100000
ENCODING_MIME = &H00040000

PR_MSG_EDITOR_FORMAT = 0H59090003
EDITOR_FORMAT_PLAINTEXT = 1
EDITOR_FORMAT_HTML = 2

sItem.Fields(PR_InetMailOverrideFormat) = ENCODING_PREFERENCE or
ENCODING_MIME or BODY_ENCODING_TEXT_AND_HTML
sItem.Fields(PR_MSG_EDITOR_FORMAT) = EDITOR_FORMAT_HTML
sItem.Send
 
Thanks!

I thought I tried what you suggested with SafeRecipient.Fields and it didn't
seem to work, but it's possible that I did something wrong. However, setting
appropriate properties on the message itself before it's being sent seems
like a better idea than doing that for every individual recipient.

Best,
Martynas
 
Why not use:

SafeItem.HTMLbody = "your data"

I use this, and all text is sent HTML

Frank
 
Hi Frank,

That's too brave of a statement, have you tested under different versions
and configurations of Exchange Server?

Martynas
 
Back
Top