Finding the handle of a email message

  • Thread starter Thread starter Andy Trezise
  • Start date Start date
A

Andy Trezise

Hi

I'd like to store the handle (EntryID) of a message before it is sent so
that I can quickly retrieve it later.

Problem is the message doesn't seem to have any unique handle before it is
actually sent which is then too late as I have no way of getting back to it.

oOutlook = CREATEOBJECT("Outlook.Application")

oNewMessage = oOutlook.CreateItem(0)

oNewMessage.Recipients.Add(cEmailAddress)

oNewMessage.Recipients.ResolveAll

oNewMessage.Display <-------------------- the EntryID is blank
at this point
 
EntryID is always blank until an item is sent or saved. And it can
change if it is moved.

If all sent messages are being saved in the Sent Items folder you can
code an ItemAdd event handler for the Items collection of the Sent
Items folder and when that fires capture the EntryID of the item.
Another possibility is to create a user defined field in the item that
has a unique GUID or number that you assign to it and that can be used
later for capturing the item again.
 
http://www.slipstick.com/dev/code/zaphtml.htm#cw shows an ItemAdd
handler for the Inbox's Items collection that converts incoming HTML
emails into Rich Text format. The setup and general organization of
that code can be used to set up an ItemAdd handler for the Items
collection of the Sent Items folder.

EntryID is a GUID (globally unique identifier). One is assigned when
an item is saved and if the item is not moved or deleted that GUID is
guaranteed to be unique and stable. It can change however if you move
or delete the item. EntryID's are used, in conjunction with StoreID's
which uniquely identify an Outlook mail store, to retrieve Outlook
items. For example the NameSpace.GetItemFromID method uses both
(StoreID optionally).

If you take EntryID for an item and copy it to a user defined property
you can search that property for the original EntryID of the item.
That user property won't change even if the item is moved or deleted.

You can also create a GUID by using a call to the Win32 API or by
using CDO 1.21's Session.CreateConversationIndex method. Another way
to create a probably unique tag for an item is to concatenate things
like the user name, time, date and possibly a number you increment in
your code after use.
 
Back
Top