Help with EntryID

  • Thread starter Thread starter noone
  • Start date Start date
N

noone

I am trying to capture the EntryID of a message, delete it,
then delete it again from 'Deleted Items'.

I can delete the message(s) just fine, however it bonks out
below (see NOTEs).

Dim objNameSpace As Outlook.NameSpace
Set objNameSpace = Application.Session
Dim objItem As Object
Dim strEntry

(removed extra code not needed for this example)

strEntry = objItem.EntryID
objItem.Delete
'NOTE: All above works just fine, deleting the message
Set objItem = objNameSpace.GetItemFromID(strEntry)
objItem.Delete
'NOTE: The 2 lines above error out

Am I completely off ?
Thanks.
 
EntryID changes when the item is moved. You can trap the ItemAdd event
on the Deleted Items folder's Items collection or you can use CDO or
Redemption, where Delete hard deletes the item and doesn't move it to
Deleted Items.
 
thanks. this is the function that i am using to "get" the smtp addy from the
message
(using redemption).

the line objSMail.Delete deletes the message, but it still goes into the
deleted items
box. is there another way to "delete" the message ?

Function R_GetSenderAddress(objMsg)
Dim strType
Dim objSenderAE
Dim objSMail
Const PR_SENDER_ADDRTYPE = &HC1E001E
Const PR_EMAIL = &H39FE001E

Set objSMail = CreateObject("Redemption.SafeMailItem")
objSMail.Item = objMsg
strType = objSMail.Fields(PR_SENDER_ADDRTYPE)

Set objSenderAE = objSMail.Sender
If Not objSenderAE Is Nothing Then
If strType = "SMTP" Then
R_GetSenderAddress = objSenderAE.Address
ElseIf strType = "EX" Then
R_GetSenderAddress = objSenderAE.Fields(PR_EMAIL)
End If
End If


objSMail.Delete

Set objSenderAE = Nothing
Set objSMail = Nothing

End Function
 
If you use the Object Browser to view the SafeMailItem object you will
see that it has no Delete method. So calls to that method are passed
to the underlying Outlook object (MailItem) and its Delete method,
which leaves the item in Deleted Items.

You could use Item.EntryID and Item.Parent.StoreID to get the item as
a CDO Message object and use CDO's Delete method, which will hard
delete the item.

Redemption's MessageItem object does have a Delete method. The trick
there would be to get the item as a Redemption MessageItem. For that
you could get the Redemption MAPIFolder for the folder, get the
MAPIFolder.Items collection which are SafeItems, then iterate the
collection to get the MessageItem you want.

Quicker but even more complex would be to get the MAPITable for the
SafeItems and use the MAPITable Filter to directly get the item. You
would filter on the EntryID you want. You would have to make sure to
check for both the short-term and long-term EntryID's to make sure you
got what you wanted.

Dmitry has an example of that in the filtering examples for MAPITable
on his Web site.
 
Back
Top