PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook VBA Programming vba script: add contact + distribution list

Reply

vba script: add contact + distribution list

 
Thread Tools Rate Thread
Old 07-11-2004, 08:21 PM   #1
guy
Guest
 
Posts: n/a
Default vba script: add contact + distribution list


I've set up a rule so that when a certain subject is received then a message
pops up and that email is copied to a certain folder - simple enough and no
mystery how to do that.

Now I'd like to add a bit of VBA code such that when that rule is
encountered the sender's email address is:
1. Added to the Contacts list
2. Put in a certain category
3. Added to a Distribution List

I've had a search around the VBA documentation but don't see the objects (or
recognize which objects) I need to use make this sort of thing happen. Is
there a tutorial about this sort of thing on the web?

Thanks.


  Reply With Quote
Old 08-11-2004, 07:57 AM   #2
Michael Bauer
Guest
 
Posts: n/a
Default Re: vba script: add contact + distribution list

ad 1)
For adding an item to the default contacts just call
Application.CreateItem(olContactItem).

If it isn´t the default contact list you need a reference to the folder
and then call the MapiFolder.Items.Add method. You can walk through the
hierarchie of folders (each folder has a folders collection) or use
Sue´s sample "GetFolder"
(http://www.outlookcode.com/d/code/getfolder.htm).

ad 2)
Both methods CreateItem and Items.Add returns the new object which has a
category property. This is a semicolon separated list. Just append the
new value (if need be separated by a semicolon).

ad 3)
First again you need a reference to the folder which stores the DL. With
MapiFolder.Items.Item("yourDLName") you can get a reference to the DL if
the name is unique. Otherwise you will need the EntryID or to loop
through the folder.

For the DistributionList.AddMembers method there is a good sample in the
online help of OL VBA.


--
Viele Grüße
Michael Bauer


"guy" <wildfiction@hotmail.com> wrote in message
news:Os8SWdQxEHA.1988@TK2MSFTNGP12.phx.gbl...
> I've set up a rule so that when a certain subject is received then a

message
> pops up and that email is copied to a certain folder - simple enough

and no
> mystery how to do that.
>
> Now I'd like to add a bit of VBA code such that when that rule is
> encountered the sender's email address is:
> 1. Added to the Contacts list
> 2. Put in a certain category
> 3. Added to a Distribution List
>
> I've had a search around the VBA documentation but don't see the

objects (or
> recognize which objects) I need to use make this sort of thing happen.

Is
> there a tutorial about this sort of thing on the web?
>
> Thanks.
>
>


  Reply With Quote
Old 08-11-2004, 12:34 PM   #3
guy
Guest
 
Posts: n/a
Default Re: vba script: add contact + distribution list

Thanks Michael - that looks like just what I need. I will try that out
tomorrow when I have a moment on my hands. Thanks again.


"Michael Bauer" <mib00@t-online.de> wrote in message
news:ekcFJvWxEHA.1400@TK2MSFTNGP11.phx.gbl...
> ad 1)
> For adding an item to the default contacts just call
> Application.CreateItem(olContactItem).
>
> If it isn´t the default contact list you need a reference to the folder
> and then call the MapiFolder.Items.Add method. You can walk through the
> hierarchie of folders (each folder has a folders collection) or use
> Sue´s sample "GetFolder"
> (http://www.outlookcode.com/d/code/getfolder.htm).
>
> ad 2)
> Both methods CreateItem and Items.Add returns the new object which has a
> category property. This is a semicolon separated list. Just append the
> new value (if need be separated by a semicolon).
>
> ad 3)
> First again you need a reference to the folder which stores the DL. With
> MapiFolder.Items.Item("yourDLName") you can get a reference to the DL if
> the name is unique. Otherwise you will need the EntryID or to loop
> through the folder.
>
> For the DistributionList.AddMembers method there is a good sample in the
> online help of OL VBA.
>
>
> --
> Viele Grüße
> Michael Bauer
>
>
> "guy" <wildfiction@hotmail.com> wrote in message
> news:Os8SWdQxEHA.1988@TK2MSFTNGP12.phx.gbl...
>> I've set up a rule so that when a certain subject is received then a

> message
>> pops up and that email is copied to a certain folder - simple enough

> and no
>> mystery how to do that.
>>
>> Now I'd like to add a bit of VBA code such that when that rule is
>> encountered the sender's email address is:
>> 1. Added to the Contacts list
>> 2. Put in a certain category
>> 3. Added to a Distribution List
>>
>> I've had a search around the VBA documentation but don't see the

> objects (or
>> recognize which objects) I need to use make this sort of thing happen.

> Is
>> there a tutorial about this sort of thing on the web?
>>
>> Thanks.
>>
>>

>



  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