PC Review


Reply
Thread Tools Rate Thread

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

 
 
Ted Byers
Guest
Posts: n/a
 
      19th Jan 2004
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


 
Reply With Quote
 
 
 
 
Norm Cook
Guest
Posts: n/a
 
      20th Jan 2004
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.


"Ted Byers" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Ted Byers
Guest
Posts: n/a
 
      20th Jan 2004
Thanks Norm,

That is just what I was looking for.

Thanks

Ted

"Norm Cook" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>
>
> "Ted Byers" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >

>
>



 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding event handler in C# ? Rich P Microsoft C# .NET 5 8th Mar 2009 08:18 AM
adding a event handler in MFC application for c# event Mayur Gadhave Microsoft VC .NET 2 30th Aug 2006 08:14 AM
adding a event handler in MFC application for c# event Mayur Gadhave Microsoft C# .NET 0 30th Aug 2006 07:38 AM
Adding an event handler in a sub Just Me Microsoft VB .NET 6 3rd Sep 2004 09:57 PM
Adding an event handler in a sub Just Me Microsoft VB .NET 7 10th Aug 2004 01:29 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:59 AM.