PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook VBA Programming Catch delete in MailItem_Close event

Reply

Catch delete in MailItem_Close event

 
Thread Tools Rate Thread
Old 26-04-2004, 04:14 PM   #1
|{arl Shtoshek
Guest
 
Posts: n/a
Default Catch delete in MailItem_Close event


Hi, All!

Is there ANY way to determine if the MailItem is being deleted in its
MailItem_Close event?

I'm doing a check whether the MailItem is changed and if it is, I
display the "Do you want to save changes?" dialog (with a
MsgBox(...)). If the user chooses "Yes", I call Inspector.Close
olSave. Here "Inspector" is the wrapper class which contains the
MailItem object.

The problem is - if the MailItem is changed, but is being deleted, I'm
displaying the "do you want to save changes" dialog anyway, because I
don't know that it's being deleted.

I'm using VB6 and developing for OL2000

The code looks somewhat like this:

Private Sub m_objMail_Close(Cancel As Boolean)
Dim iRetVal As Integer

If m_objMail.Saved = False Then

'Here I would like to know if m_objMail is being deleted

iRetVal = MsgBox("Save changes?", vbYesNoCancel)
Select Case iRetVal
Case vbYes
m_objInsp.Close olSave
Case vbNo
m_objInsp.Close olDiscard
Case vbCancel
Cancel = True
End Select
Else
m_objInsp.Close olDiscard
End If

End Sub

TIA,
Karls
  Reply With Quote
Old 26-04-2004, 06:47 PM   #2
Ken Slovak - [MVP - Outlook]
Guest
 
Posts: n/a
Default Re: Catch delete in MailItem_Close event

You could trap ItemAdd in the Deleted Items folder's Items collection but
I'm not sure if that would happen before Item_Close or during or after, and
it wouldn't fire if the user hard-deleted the item using Shift+Delete.
There's really no good way to do what you want but you can experiment with
the timing of the ItemAdd event to see if it does anything at all for you.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"|{arl Shtoshek" <karls@latnet.lv> wrote in message
news:311f8a3d.0404260714.f2b2368@posting.google.com...
> Hi, All!
>
> Is there ANY way to determine if the MailItem is being deleted in its
> MailItem_Close event?
>
> I'm doing a check whether the MailItem is changed and if it is, I
> display the "Do you want to save changes?" dialog (with a
> MsgBox(...)). If the user chooses "Yes", I call Inspector.Close
> olSave. Here "Inspector" is the wrapper class which contains the
> MailItem object.
>
> The problem is - if the MailItem is changed, but is being deleted, I'm
> displaying the "do you want to save changes" dialog anyway, because I
> don't know that it's being deleted.
>
> I'm using VB6 and developing for OL2000
>
> The code looks somewhat like this:
>
> Private Sub m_objMail_Close(Cancel As Boolean)
> Dim iRetVal As Integer
>
> If m_objMail.Saved = False Then
>
> 'Here I would like to know if m_objMail is being deleted
>
> iRetVal = MsgBox("Save changes?", vbYesNoCancel)
> Select Case iRetVal
> Case vbYes
> m_objInsp.Close olSave
> Case vbNo
> m_objInsp.Close olDiscard
> Case vbCancel
> Cancel = True
> End Select
> Else
> m_objInsp.Close olDiscard
> End If
>
> End Sub
>
> TIA,
> Karls



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off