I've written a tiny piece of combined CDO/Outlook code to permanently delete
a message. Half the time, after the message is deleted, it still shows in
the folder. But if I navigate to another folder, then navigate back to the
original folder, the message is gone. Any suggestions about how to make it
disappear right away? Thanks.
Here's the code:
Public Sub PermanentlyDeleteItem(objItem As Object)
'permanently deletes objItem from store
Dim objCDOMsg As MAPI.Message
Dim objCDOSession As MAPI.Session
Dim strEntryID As String
Dim strStoreID As String
On Error Resume Next
If Not objItem Is Nothing Then
Set objCDOSession = New MAPI.Session
objCDOSession.Logon "", "", False, False
strEntryID = objItem.EntryID
strStoreID = objItem.Parent.StoreID
Set objCDOMsg = objCDOSession.GetMessage(strEntryID, strStoreID)
If Not objCDOMsg Is Nothing Then
objCDOMsg.Delete
End If
End If
Set objItem = Nothing
Set objCDOMsg = Nothing
objCDOSession.Logoff
Set objCDOSession = Nothing
Set objCDO = Nothing
End Sub
Tom Rizzo [MSFT] - 06 Nov 2005 16:20 GMT
The message shows in Outlook? Are you running cached mode since CDO will
delete it off the server and then it needs to sync to the Outlook client.
Tom

Signature
Looking for a good book on programming Exchange, Outlook, ADSI and
SharePoint? Check out http://www.microsoft.com/MSPress/books/5517.asp
> I've written a tiny piece of combined CDO/Outlook code to permanently
> delete
[quoted text clipped - 32 lines]
> Set objCDO = Nothing
> End Sub
Mike P. - 07 Nov 2005 08:15 GMT
No, we're not running Outlook in cached mode. That's what's weird.
> The message shows in Outlook? Are you running cached mode since CDO will
> delete it off the server and then it needs to sync to the Outlook client.
[quoted text clipped - 37 lines]
> > Set objCDO = Nothing
> > End Sub