Redemption - problem with Save

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using Redemption to circumnavigate Outlook 2003 security on my setup
while using some code to handle new messages. When I set the SafeItem.Item =
CurrentItem, I have to precursor this with a CurrentItem.Save so that I can
access some of the item's properties through the SafeItem object. This works
fine, the only problem is if I ever decide to abort my message (i.e. close
and say No to saving) this obviously still leaves a stray copy of the message
in my Drafts from the earlier CurrentItem.Save. Does anyone know of a way to
stop or fix this?
 
It's a bit clumsy but I've added the following to my Application_Startup
event as a solution. Any suggestions/improvements gratefully received - or
preferably a way of doing this when the message is first created:

Set myNS = Application.GetNamespace("MAPI")
Set myItems = myNS.GetDefaultFolder(olFolderDrafts).Items
myCount = myItems.Count
For n = myCount To 1 Step -1
Set myMail = myItems.Item(n)
Set SafeItem.Item = myMail
myStr = SafeItem.Body & SafeItem.SentOnBehalfOfName & SafeItem.Subject
If SafeItem.Recipients.Count = 0 And SafeItem.Attachments.Count = 0
And myStr = "" Then myMail.Delete
End If
Next
 
After you issue the Save command grab the EntryID of the item. If you want
to delete it get it as a Redemption item of some kind and delete it. Use
Redemption to do that so the item doesn't end up in the Deleted Items
folder.
 
One workaround could be to use a global (boolean) flag - implement the
Item_Write event hander. Set a global flag, call Save, Outlook will call
your implementation of the Item_Write event hander. If the flag is set, your
code is calling Save, otherwise it is the user explciitly saving the
message.
If the user never saved the message, it should be safe for you to delete it.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Thanks Dmitry - both for your response and for Redemption itself (which has
been a lifesaver!). I've gone with a combination of flags, the Write event,
and the Close event to ensure dummy messages are deleted. Not a complete
solution as Ken points out: they're still ending up in the Deleted Items
folder so I'll have to look more closely into the possibility of using
Redemption to fully delete.
 
Back
Top