Linked attachments

M

Michael Bauer

Hi @all,

I´ve a ContactItem with a linked item (MailItem e.g.) attached. For
getting the MailItem I think I need the EntryID, but obvioulsy I´m
unable to find it.

The Attachment´s PR_STORE_RECORD_KEY and PR_MAPPING_SIGNATURE both
contains a part of the EntryID, but I´m missing the last 4 Bytes
(expecting that the first 4 Bytes always are 0).
 
D

Dmitry Streblechenko

Embedded message attachments do not have entry ids. They exist only in the
context of the parent message, never standalone.

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

Michael Bauer

Thanks, Dmitry. So the only method getting the original message would be
searching by its subject?
 
D

Dmitry Streblechenko

But to get the embedded message, you need to open it somehow, so you already
know where it comes from, right?

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

Michael Bauer

Maybe I should know but I don´t... :-(

It´s PR_ATTACH_METHOD = 6, the item can be from one of my *.pst files
and the only info that I have (or that I can find at least) is the
DisplayName (that could be changed) and a part of the original´s
EntryID.

I could call SaveAsFile first, of course. Is that the way OL is doing,
too?
 
D

Dmitry Streblechenko

I am still not sure I xcompletely understand - are you simply trying to
programmatically manipulate a ContactItem object which may have an embedded
MailItem attacced? Or a MailItem is displayed by Outlook and you are trying
to figure out where Inspector.CurrentItem came from?

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

Michael Bauer

It´s the first point. For the MailItem e.g. it maybe interesting to
know, when it came in. Or if it´s not a MailItem, but a TaskItem, then I
maybe want to know if the task is done already.

For getting this infos do I really first have to save the items as
files?
 
D

Dmitry Streblechenko

So you get these items from an active inspector, right?
I don't think there is a way to know for sure which item hosts the other
item in question though.

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

Michael Bauer

Now I´m not sure if this is the answer on my question. If so, sorry for
confusing you, Dmitry :)

The host, I think, do I have - it´s a ContactItem. The user has a
ContactItem opened and clicks Insert/Item. (I hope this is the correct
translation.) Then he can insert e.g. a MailItem as text, as attachment,
or as link. He inserts the item as link.

If I want to know programmatically the original MailItem´s data then it
seems to be necessary to save the item as file and call
GetItemFromTemplate.

Because the attachment´s PR_MAPPING_SIGNATURE is the original Mailitem´s
EntryID without its leading 4 bytes (0) and its last 4 bytes, which
obviously depend on the *.pst, I thought there is a way to use a call of
GetItemFromID.

Anyway, thanks for your time, Dmitry!
 
D

Dmitry Streblechenko

Oh, I see what you mean - so essentially you are trying to access the
embedded message attachment data as if that was a regular message. Note that
thee orginal item could be deleted.
You can use either CDO 1.21 (Attachment.Source - retruns Message) or
Redemption (Attachment.EmbeddedMsg).
Note that PR_MAPPING_SIGNATURE will be thee same for all objects in a
particular store. It has absolutely nothing to with entry ids.

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

Michael Bauer

Hi Dmitry,
Note that
thee orginal item could be deleted.

Thanks, I put it on my list.

Attachment.Source was my first test but it returns an empty string.
Redemption (Attachment.EmbeddedMsg) is Nothing.

(If it´s important, I´m testing on OL 2k without any SP´s, CW-Mode.)
Note that PR_MAPPING_SIGNATURE will be thee same for all objects in a
particular store. It has absolutely nothing to with entry ids.

In fact, you´re right.

Here´s my little test:

Public Sub GetOriginalMessageFromAttachment_1()
On Error Resume Next

Dim mpMsg As MAPI.Message
Dim mpAtt As MAPI.Attachment
Dim mpSess As MAPI.Session

Dim obj As Object

Dim rdAtt As Redemption.Attachment
Dim rdItem As Object
Dim rdMsg As Redemption.MessageItem

Set mpSess = LogOn()

' Returns a Mapi object by the CurrentItem´s EntryID and StoreID
Set mpMsg = GetMessage(Application.ActiveInspector.CurrentItem,
mpSess)
Set mpAtt = mpMsg.Attachments(4)

' result: mpAtt.Source = ""
Set obj = mpAtt.Source

Set rdItem = CreateObject("redemption.safecontactitem")
rdItem.Item = Application.ActiveInspector.CurrentItem
Set rdAtt = rdItem.Attachments(4)

' result: rdAtt.EmbeddedMsg = Nothing
Set rdMsg = rdAtt.EmbeddedMsg


rdItem.Item = Nothing
Set rdAtt = Nothing
Set rdItem = Nothing
End Sub
 
D

Dmitry Streblechenko

Hmmmm... Did you try to test it with only one attachment? I can see the
rdItem.Attachments(4) line - the order of attachments you see in the Outlook
UI can be different from what you get programmatically.
If you look at that message using OutlookSpy (click IMessage), what is the
PR_ATTACH_METHOD property value?

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

Michael Bauer

Unfortunately it doesn´t matter. I have some test items with many
attachments and also one with only one attachment, tested with Task- and
ContactItems.

PR_ATTACH_METHOD is 6. I´ve checked it with OutlookSpy and also the
index is correct (of course:)

Do you have another idea by any chance?
 
D

Dmitry Streblechenko

Can you save the parent item as an MSG file, zip it (important!) and send it
to my private e-mail address?

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