Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Add-Ins / January 2004

Tip: Looking for answers? Try searching our database.

Adding an event handler for Outlook using VB (not VBA)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ted Byers - 19 Jan 2004 16:58 GMT
In my COM AddIn class, I have a declaration,in a VB project) as follows:

Private WithEvents objContactItem As Outlook.ContactItem

As I understand it, this allows me to be notified that events associated
with editing, adding or deleting a ContactItem have occured.  The question
is, "How do I add the event handler?"  Is it to be a member function of my
COM class, or a separate function, and how do I ensure that my function is
called?  (I.e., I know how to add a function to a class, but I don't know
how to tell Outlook which function to call for any given event.)  While I
expect this to be as simple as creating a callback function and passing the
pointer to Outlook, or even as simple as adding a member function to my
class with an appropriate name, but then the question is what name.  I have
yet to find this documented anywhere.

I guess there is another question, in that I need to know how objContactItem
is initialized.  I need to do so in two contexts.  In one case, I will have
contact information and I will need to first put that information into
either a new ContactItem (in the case of adding a contact) or into an
existing ContactItem (in the case of an edit) in which case I'd need to be
able to find the right contact already in the Outlook database in order to
make the edit.  In the second case, I will need to retrieve the new contact
data associated with an edit or add event.

This must be simple to do, but I haven't found what I need to know in the
documentation I have.

Any assistance will be greatly appreciated.

Thanks

Ted
Norm Cook - 20 Jan 2004 12:10 GMT
If I understand you question correctly, assuming you have added a reference
to the Outlook Object Library and also assuming this statement was added to
a form or class module
> Private WithEvents objContactItem As Outlook.ContactItem

If you will drop down the left hand combo box at the top of the code module,
you should find
objContactItem in the list.  Click on that and the default event will appear
in your code module.  Now if you drop down the right hand combo, you will
see all the other available events.

> In my COM AddIn class, I have a declaration,in a VB project) as follows:
>
[quoted text clipped - 28 lines]
>
> Ted
Ted Byers - 20 Jan 2004 15:36 GMT
Thanks Norm,

That is just what I was looking for.

Thanks

Ted

> If I understand you question correctly, assuming you have added a reference
> to the Outlook Object Library and also assuming this statement was added to
[quoted text clipped - 44 lines]
> >
> > Ted
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.