Thanks, Ken.
I'm using Extended MAPI anyway, hence the seeming redundancy of using
Redemption. However, I can't figure out how it's creating an
Outlook::MailItem, setting the properties of its underlying MAPIObject, and
getting it to display right. At least, that's what I assume it's doing...
you certainly can't do it the other way around (i.e. create a MAPI item and
then attach it to an Outlook::MailItem).
P.S. I have your "Outlook 2007 Programming" in front of me. Thanks for the
great book.
"Ken Slovak - [MVP - Outlook]" wrote in message
...
The Redemption route is probably your best option, otherwise you have to
use Extended MAPI (unmanaged C++ or Delphi only) to replicate what
Redemption is doing.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
"Cain T. S. Random" wrote in message
...
Does anybody know how to get an Outlook.MailItem, set its underlying MAPI
properties, and display it appropriately without saving it?
I have an RFC 822 message that I need to manipulate and display in
Outlook, but I want to avoid saving it so that it doesn't end up being
replicated back to their Exchange server. Even if I delete the item
immediately after displaying it, it may still incur the network cost of
being uploaded, and if deleted item retention is enabled, it'll still
hang around.
Outlook doesn't expose any way to do this. You can ask it to open a .msg
file, but .msg files have their own problems (e.g. with large numbers of
recipients) and the .msg file has to be cleaned up at some point. Also,
I may want to reply to or forward the message rather than merely display
it, which is tricky with just the command-line invocation of Outlook.
I tried creating a Outlook::MailItem through the Outlook API, calling
SetProps on its MAPIITEM member, and then displaying it, but that was all
sorts of fail. It created in the Drafts folder no matter what I tried to
do, and the message was blank rather than reflecting the properties I'd
set (even though OutlookSpy showed the right properties on the message).
These are probably fixable issues eventually, but I suspect I'm coloring
way outside the lines here.
I've also tried using Redemption, which will import the RFC 822 message
and display it, but seems to have problems showing it as sent The
following script will display a message as unsent unless it's saved and
reopened:
Set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
Set Msg = Session.GetDefaultFolder(16).Items.Add(6)
Msg.Sent = True
Msg.Import "x:\dev\test.eml", 1024
Msg.Display
Redemption will, however, load the .msg file and let me manipulate the
Outlook item however I wish. My current jerryrigged solution is to
convert the RFC 822 file to a .msg file then use Redemption to load the
.msg file, but that seems overly elaborate. I'm not sure how Redemption
is doing this under the hood-- the resulting Outlook message shows up as
not being a child of any folder and not savable, which is pretty cool;
it's almost identical to how Outlook shows .msg files.
So: does anybody have any better ideas of how to accomplish any of this?
Cain T. S. Random
Software Engineer
Barracuda Networks Inc.
Tel: 734-302-3001 x7019
Mobile: 734-709-2443
Fax: 734-302-3067