You can't set the value of an object to a string value.

You need to do everything I mentioned, handling
Application.Inspectors.NewInspector and testing for
Inspector.CurrentItem.Class to be olMail. That will give you a handle to the
mail item and then you need to instantiate your class so it can handle the
Close event of the mail item.

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

<landau@skiz.net> wrote in message
news:e92ccb88-7461-43f2-aaaa-d587bac15aaf@e4g2000hsg.googlegroups.com...
> Thanks. I've tried that. This is what I have:
> In a Class Module call EdClass:
> Public WithEvents myEdItem As Outlook.MailItem
> Private Sub Class_Initialize()
> Set myItem = Application.ActiveInspector.CurrentItem
> End Sub
> Private Sub myEdItem_Close(Cancel As Boolean)
> If Not myItem.Saved Then
> MsgBox " The item was closed."
> End If
> End Sub
>
>
> Then in a standard Module, I have:
> Dim myClass As New EdClass
> Sub Register_Event_Handler()
> Set myClass.myEdItem = "Outlook.mailitem"
>
> End Sub
>
>
> But I get an error that an Object is needed when trying to instantiate
> the class (set myClass...).
>
> Any thoughts?
>
> Thanks
> -Ed
06 Feb 2008Help writing a macro to move emails.landau@skiz.net
06 Feb 2008|- RE: Help writing a macro to move emails.Anand.V.V.N
22 Jan 2010|  \ imap move deleted email to TRASH in outlook.andre cloete
06 Feb 2008\ Re: Help writing a macro to move emails.Ken Slovak - [MVP - O...
06 Feb 2008   \ Re: Help writing a macro to move emails.landau@skiz.net
06 Feb 2008      \ Re: Help writing a macro to move emails.Ken Slovak - [MVP - O...
06 Feb 2008         \ Re: Help writing a macro to move emails.landau@skiz.net
07 Feb 2008            |- Re: Help writing a macro to move emails.landau@skiz.net
07 Feb 2008            \ Re: Help writing a macro to move emails.Ken Slovak - [MVP - O...
07 Feb 2008               \ Re: Help writing a macro to move emails.landau@skiz.net
07 Feb 2008                  \ Re: Help writing a macro to move emails.Ken Slovak - [MVP - O...
13 Mar 2008                     \ Re: Help writing a macro to move emails.sandeepthanki@gmail.com
Contact Us
All times are in (US) Eastern Daylight Time (GMT -4:00)