• Subject: Re: Deleting a draft of an email
  • Author: kevotheclone
  • Date: 13 Nov 2009
  • References: 1 2
Thanks Ken. Yes thinking about it more I realize that I can't delete a MailItem from within either the MailItem.Close event or the Inspector.Close event as both Close events are really BeforeClose events. It would be nice if the Inspectors collection had a CloseInspector event to balance out the NewInspector event and if there was a way to capture the user's response to the "Do you want to save changes?" dialog in a global variable, but both of these items are probably impossible in Outlook 2003. I could go the timer route, but ideally I'd still like to know the user's response to the "Do you want to save changes?" dialog box, so that I don't delete an email that they have explicitly stated that they want to store in the Drafts folder. Maybe I'll have to look at the Windows API for an answer. "Ken Slovak - [MVP - Outlook]" <kenslovak@mvps.org> wrote in message news:OZ5OEpGZKHA.5852@TK2MSFTNGP05.phx.gbl...
>I use a timer that fires at regular intervals that takes a list of entry >id's and uses that to delete unwanted items. > > -- > Ken Slovak > [MVP - Outlook] > http://www.slovaktech.com > Author: Professional Programming Outlook 2007. > Reminder Manager, Extended Reminders, Attachment Options. > http://www.slovaktech.com/products.htm > > > "kevotheclone" <kevotheclone@hotmail.com> wrote in message > news:uRpWnK$YKHA.5544@TK2MSFTNGP02.phx.gbl...
>> I've got a Outlook COM Addin that appends text to an email's Subject and >> Body when a specific button is clicked. One problem I encountered is >> with a >> new email, if the user types anything into the subject line before >> clicking >> the button I am unable to read the subject's text because the email has >> not been saved. >> Without being able to read the subject's text, I can't append text, only >> blindly overwrite it. To resolve this I check the MailItem.Saved >> property >> and if it's not already saved I save it with the MailItem.Save() method. >> This works well and by itself is not a problem. >> >> If Not miCurrent.Saved Then >> miCurrent.Save >> strEntryID = miCurrent.EntryID >> End If ' Not miCurrent.Saved >> >> However after I save the email there's a copy in the user's Draft folder. >> If >> the user Sends the email or Deletes the email it will be automatically >> deleted from the Drafts folder, but if the user Closes the email and >> answers >> "No" to "Do you want to save changes?" the email remains in their Drafts >> folder. So my problem is trying to delete the email. I've saved the >> EntryID >> of the email right after I save it and I know it's the correct EntryID >> via debugging MsgBoxes. >> >> I've tried deleting the email within it's Close event, and yes >> "miCurrent" is declared in my Class "WithEvents": >> Private WithEvents miCurrent As Outlook.MailItem >> >> Private Sub miCurrent_Close(Cancel As Boolean) >> miCurrent.Delete >> End Sub ' miCurrent_Close(Cancel As Boolean) >> >> I've also tried deleting the email from the Inspector's Close Event, and >> yes the "mailInspector" is declared in my Class "WithEvents": >> Public WithEvents mailInspector As Outlook.Inspector >> >> Private Sub mailInspector_Close() >> Dim nsMapi As Outlook.NameSpace >> Dim miToDelete As Outlook.MailItem >> Dim fldrDeleted As Outlook.MAPIFolder >> >> Set nsMapi = Outlook.GetNamespace("MAPI") >> Set miToDelete = nsMapi.GetItemFromID(strEntryID) >> >> MsgBox miToDelete.Subject ' For debugging to see if I've got the correct >> MailItem >> >> miToDelete.Delete >> End Sub ' mailInspector_Close() >> >> In both cases I get: >> Run-time error: '-1698430712 (9ac40108)': >> Unable to complete the command. >> >> I've read this thread, which gave me some of the ideas, to work with but >> the problem still isn't resolved. How can you reliable delete a MailItem >> on a Close event? Or is there another Object/Event that I should use? >> http://groups.google.com/group/microsoft.public.office.developer.outlook.vba/browse_thread/thread/e5702708a8099746/a321f5a9bb627e0?hl=en&q=How+do+I+delete+draft+emails%3F >> >> Thanks in advance for any assistance anyone can provide! >> We're using Outlook 2003, build 11.8313.8221 SP3 >> >> >>
>
12 Nov 2009Deleting a draft of an email.kevotheclone
13 Nov 2009\ Re: Deleting a draft of an email.Ken Slovak - [MVP - O...
13 Nov 2009   \ Re: Deleting a draft of an email.kevotheclone
Contact Us
All times are in (US) Eastern Daylight Time (GMT -4:00)