How to enable the Inbox ItemAdd event in a COM AddIn 
Author Message
 How to enable the Inbox ItemAdd event in a COM AddIn

The environment is Outlook 2000 on Win2K Pro. I'm developing a COM AddIn in
VB6.

I need to know when a message is added to the Inbox.  Here's what I'm trying
to do:

Private WithEvents oApplication         As Outlook.Application
Private WithEvents oInbox               As Outlook.Items

Private Sub AddinInstance_OnConnection(ByVal Application As Object, _
                                       ByVal ConnectMode As
AddInDesignerObjects.ext_ConnectMode, _
                                       ByVal AddInInst As Object, _
                                       Custom() As Variant)
    Set oApplication = Application
    Set oInbox =
oApplication.GetNamespace("MPAI").GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub oInbox_ItemAdd(ByVal Item As Object)
    MsgBox "At Item Add"
End Sub

At Outlook Startup, I get the following error:

Run-time error '-1975058345 (8a470057)'
Could not complete the operation.  One or more parameter values are not
valid.

If I comment out the Set oInbox in OnConnection, I don't get the error.  Any
idea what I'm doing wrong?

Pete



Sun, 31 Jul 2005 03:42:51 GMT  
 How to enable the Inbox ItemAdd event in a COM AddIn
Sorry -- finally figured it out.  I was setting oInbox = oApplication...  I
changed it to Set oInbox = Application... and it works fine.

Thanks anyway,

Pete


Quote:
> The environment is Outlook 2000 on Win2K Pro. I'm developing a COM AddIn
in
> VB6.

> I need to know when a message is added to the Inbox.  Here's what I'm
trying
> to do:

> Private WithEvents oApplication         As Outlook.Application
> Private WithEvents oInbox               As Outlook.Items

> Private Sub AddinInstance_OnConnection(ByVal Application As Object, _
>                                        ByVal ConnectMode As
> AddInDesignerObjects.ext_ConnectMode, _
>                                        ByVal AddInInst As Object, _
>                                        Custom() As Variant)
>     Set oApplication = Application
>     Set oInbox =
> oApplication.GetNamespace("MPAI").GetDefaultFolder(olFolderInbox).Items
> End Sub

> Private Sub oInbox_ItemAdd(ByVal Item As Object)
>     MsgBox "At Item Add"
> End Sub

> At Outlook Startup, I get the following error:

> Run-time error '-1975058345 (8a470057)'
> Could not complete the operation.  One or more parameter values are not
> valid.

> If I comment out the Set oInbox in OnConnection, I don't get the error.
Any
> idea what I'm doing wrong?

> Pete



Sun, 31 Jul 2005 04:47:27 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. OnDisconnection event in a COM Addin

2. ItemChange event firing off after ItemAdd event

3. OnDisconnection event in a COM addin

4. using COM/DCOM within a COM-Addin ???

5. Rules and VBA ItemAdd Events

6. Copying Items in the ItemAdd() Event?

7. Deleting Attachments in ItemAdd event

8. ItemAdd, ItemChange events

9. VBA: ItemAdd Event - pls help

10. Problems with Macro running on ItemAdd event

11. Way to fire event ItemAdd automatically?

12. Outlook2000 Object Model, ItemAdd Event

 

 
Powered by phpBB® Forum Software