Persistent MAPI Properties

A

Andrew Roesch

Hello,

What I am attempting to do is to set a value in a mail message on the
senders side that will be accessible on the recipients side. I was
under the impression that Mapi properties, using the UserProperties
collection was the way to go.

I was using the UserProperties collection but the property was always
gone on the reciepients side. In reading the MAPI API it seems like
this should be possible to create transmitable properties.

What am I doing wrong?
 
S

Sue Mosher [MVP]

This should work, but only if you are sending the message in rich-text format.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
A

Andrew

This should work, but only if you are sending the message in rich-text
format.

Then how do I send a message in rich-text format programmatically?
What are the consequences of sending all mails in rich-text format?
Here is the code I use to send messages written in c# and using
redemption.

SafeMailItem safeMailItem = new SafeMailItem();
// Begin the Forward Process
// Creates a Forward Message
MailItem forward = mailItem.Forward();
// Sets forward message as the SafeMAilItem

safeMailItem.Item = forward;
safeMailItem.Recipients.Add("Test Email");

safeMailItem.Send();
 
D

Dmitry Streblechenko

If you send in the RTF format, only Outlook users will be able to read the
data correctly - you will get the infamous winmail.dat attachment.
The only workaround is to add custom headers to the message header using
Extended MAPI, CDO 1.21 or Redemption:
http://www.dimastr.com/redemption/faq.htm#14
The sample sets the Sender header, but it can be used to add any other
header.
On the receiving side you can access PR_TRANSPORT_MESSAGE_HEADERS property
and see if your header is there.

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

Sue Mosher [MVP]

Assuming you are using Outlook 2002 or later, you can set the BodyFormat property when you create a new message. I have not tried doing this with a forward, though. Let us know if it works.

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
A

Andrew

Assuming you are using Outlook 2002 or later, you can set the
BodyFormat property when you create a new message. I have not tried
doing this with a forward, though. Let us know if it works.

Setting the BodyFormat does not work. I am currently trying Dmitry's
suggestion.
 
A

Andrew

When you do this, do you have to use a pre-exisitng header? The example
you gave works fine. I was just wondering if you can add a completely new
header instead of reusing the "From".

If not, does changing this header information have any detrimental side
effects and if so what headers would be alright to change?
 
A

Andrew

This seems to work except that it seems that some mail servers modify the
text of my header values. It is most often the addition of a carriage
return, a newline, and a tab (Ascii values 13, 10, 9). Sometimes it is
only a carriage return, and newline. There does not seem to be any
pattern to where this occurs.

How do I prevent this from happening since it makes parsing these strings
problematic?
 
D

Dmitry Streblechenko

If the header+value length exceeds 72 chars, the line must be wrapped
around, this is just an RFC 822 requirement.
To unwrap, read the next line and check if the first character is space or
tab.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top