C
Cain T. S. Random
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
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