GetItemFromID fails with 8004010F error

D

DavidB

Hello,
I am trying to permanently remove email item.

It works fine on my private POP3 mail using outlook2003.
On the work mail, outlook2003 connected to exchange server (connect mode or OffLine mode) it does not work and it fails on the attempt to get the Item using the GetItemFromId function with error 8004010F. See below the code.

Any idea why?
Or other way to remove an item?

thanks
David

---------------------------------------------
Sub DeleteDelete()
Dim myOlApp, myNameSpace, Sel, objRecip, MyItem As Object
Dim SavedEntryId, I

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")

Set Sel = Application.ActiveExplorer.Selection

For I = 1 To Sel.Count
If Sel.Item(I).Class = olMail Then
Set MyItem = Sel.Item(I)
SavedEntryId = MyItem.EntryID
MyItem.Delete
Set MyItem = myNameSpace.GetItemFromID(SavedEntryId) ' <--- Run time error 8004010F, operation failed
MyItem.Delete
End If
Next

End Sub
 
D

Dmitry Streblechenko \(MVP\)

The fact that it works under PST is pure luck - PST provider does not change
the entry id when you move a message from one folder to another.
Under Exchange that does not work, you will need to somehow identify the
message that you just deleted, open it, then delete again.

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

Hello,
I am trying to permanently remove email item.

It works fine on my private POP3 mail using outlook2003.
On the work mail, outlook2003 connected to exchange server (connect mode or
OffLine mode) it does not work and it fails on the attempt to get the Item
using the GetItemFromId function with error 8004010F. See below the code.

Any idea why?
Or other way to remove an item?

thanks
David

---------------------------------------------
Sub DeleteDelete()
Dim myOlApp, myNameSpace, Sel, objRecip, MyItem As Object
Dim SavedEntryId, I

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")

Set Sel = Application.ActiveExplorer.Selection

For I = 1 To Sel.Count
If Sel.Item(I).Class = olMail Then
Set MyItem = Sel.Item(I)
SavedEntryId = MyItem.EntryID
MyItem.Delete
Set MyItem = myNameSpace.GetItemFromID(SavedEntryId) ' <---
Run time error 8004010F, operation failed
MyItem.Delete
End If
Next

End Sub
 
G

Guest

Thanks
Once again this newsgroup is proven to be very helpfull
As in the past. when i get a good answer i proactively search for 3-4 pending questions and answer them from what i know. Others are enocuraged to do the same
Davi
 

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