Add contact information to folder other than default folder 
Author Message
 Add contact information to folder other than default folder

Quote:

> I have code to add a contact information from an Access
> table or query to the default Outlook contacts folder, but
> I could not figure out how to add it to a specific contact
> folder.

Dim myContactsFolder As Outlook.MAPIFolder
Dim myContactItem As Outlook.ContactItem

Set myContactsFolder = Session.GetDefaultFolder(olFolderContacts)
Set myContactItem = myContactsFolder.Items.Add(olContactItem)
.
.
.
myContactItem.Save

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US



Thu, 14 Apr 2005 12:00:12 GMT  
 Add contact information to folder other than default folder

Quote:
>-----Original Message-----

>> I have code to add a contact information from an Access
>> table or query to the default Outlook contacts folder,
but
>> I could not figure out how to add it to a specific
contact
>> folder.

>Dim myContactsFolder As Outlook.MAPIFolder
>Dim myContactItem As Outlook.ContactItem

-----
In this line I guess I can refer to another folder with
something like:
Dim olkApp as Outlook.Application
Set olkApp = New Outlook.Application
Set olkNameSpace = olkApp.GetNamespace("MAPI")
Set myContactsFolder = olkApp.Folders("Contacts from UK")

Quote:
>Set myContactsFolder = Session.GetDefaultFolder
(olFolderContacts)
>Set myContactItem = myContactsFolder.Items.Add

(olContactItem)

myContactItem.FirstName = MyRecordset!FirstName
etc.

Quote:
>..
>..
>..
>myContactItem.Save

>--
>Michael Harris
>Microsoft.MVP.Scripting
>Seattle WA US

>.



Thu, 14 Apr 2005 13:58:27 GMT  
 Add contact information to folder other than default folder
I have code to add a contact information from an Access
table or query to the default Outlook contacts folder, but
I could not figure out how to add it to a specific contact
folder.


Thu, 14 Apr 2005 11:27:22 GMT  
 Add contact information to folder other than default folder
Quote:
>> Dim myContactsFolder As Outlook.MAPIFolder
>> Dim myContactItem As Outlook.ContactItem

   '=====
   ' assumes the folder is at the same level as the
   ' other default folders...
   '=====
   Set myContactsFolder = Session.Folders("Contacts from UK")

Quote:
>> Set myContactItem = myContactsFolder.Items.Add (olContactItem)

> myContactItem.FirstName = MyRecordset!FirstName
> etc.

>> ..
>> ..
>> ..
>> myContactItem.Save

>> --
>> Michael Harris
>> Microsoft.MVP.Scripting
>> Seattle WA US

>> .

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US


Fri, 15 Apr 2005 02:33:51 GMT  
 Add contact information to folder other than default folder
Thank you for the response.
How would it work if it was not on the same level, if it
was in a subfolder?
Also, how do I prevent the same contact from being added
to the folder twice? Does Outlook give a message or
protect against this?

Quote:
>-----Original Message-----
>>> Dim myContactsFolder As Outlook.MAPIFolder
>>> Dim myContactItem As Outlook.ContactItem

>   '=====
>   ' assumes the folder is at the same level as the
>   ' other default folders...
>   '=====
>   Set myContactsFolder = Session.Folders("Contacts from
UK")

>>> Set myContactItem = myContactsFolder.Items.Add
(olContactItem)

>> myContactItem.FirstName = MyRecordset!FirstName
>> etc.

>>> ..
>>> ..
>>> ..
>>> myContactItem.Save

>>> --
>>> Michael Harris
>>> Microsoft.MVP.Scripting
>>> Seattle WA US

>>> .

>--
>Michael Harris
>Microsoft.MVP.Scripting
>Seattle WA US

>.



Fri, 15 Apr 2005 08:48:45 GMT  
 Add contact information to folder other than default folder

Quote:

> Thank you for the response.
> How would it work if it was not on the same level, if it
> was in a subfolder?

Set AFolder = Session.Folders("My First Level Folder")
Set AFolder = AFolder.Folders("My Second Level Folder")
Set myContactsFolder = AFolder.Folders("Contacts from UK")

Quote:
> Also, how do I prevent the same contact from being added
> to the folder twice? Does Outlook give a message or
> protect against this?

You could try (with error trapping) to get that contact item first (with the Item or Find methods).  If it doesn't exist, then add it.

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US



Fri, 15 Apr 2005 09:26:12 GMT  
 Add contact information to folder other than default folder
I'm new to Outlook and I'm looking for a way to
programmatically create a distribution lists.  Since you
guys seem to be into the Outlook object model, I was
hoping you'd have some advice for me.  This is my
situation which occurs on average once per week:

1) I have a hand written list of approximately 30 names
and internet email addresses.  (It's a class list for
{*filter*} education.)  I may or may not have "seen" these
names and addresses before.

2) From this handwritten list, I want to create a
distribution list that can be shared by me and my
coworkers.

3) This is currently done by manually typing the names and
email addresses into a distribution list through the
Outlook user interface and then forwarding the
distribution list around.  (Just typing text would be
easier).

3) At any given time, we'd like to be able to combine the
distribution lists, eliminating duplicates.

4) We'd also like to be able to eliminate retyping names
and addresses if we've seen them before.

I've envisioned a solution where I perhaps keep the
information up-to-date in a database somewhere and then
create a distribution list in outlook on demand, perhaps
by going through a text file.  I've played with the
Outlook object model, but I haven't been able to succeed
at creating the distribution lists without having a
contact item for each entry (which I seem to be able to do
manually through the user interface).  I think that means
the distribution lists aren't forwardable.  

I would really appreciate any advice you guys might have
for me.

Thanks,
Maria

Quote:
>-----Original Message-----

>> Thank you for the response.
>> How would it work if it was not on the same level, if it
>> was in a subfolder?

>Set AFolder = Session.Folders("My First Level Folder")
>Set AFolder = AFolder.Folders("My Second Level Folder")
>Set myContactsFolder = AFolder.Folders("Contacts from UK")

>> Also, how do I prevent the same contact from being added
>> to the folder twice? Does Outlook give a message or
>> protect against this?

>You could try (with error trapping) to get that contact

item first (with the Item or Find methods).  If it doesn't
exist, then add it.

- Show quoted text -

Quote:

>--
>Michael Harris
>Microsoft.MVP.Scripting
>Seattle WA US

>.



Mon, 18 Apr 2005 04:07:33 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. How to add new contacts to non-default folder

2. Public Folder Contact folders.

3. Syncronize in programmatic way, the folder Contact with the public folder

4. Saving Contacts - Changing the Default Folder

5. Save Contact in non default folder from VB

6. How to change default folder for contact button on form

7. Posting to a named folder other than the default contacts

8. create a folder or find default temp folder

9. Outlook View control - accessing folders other than Default Folder

10. How do I add a contact to a public folder programatically

11. Adding/Deleting Contacts in Public Folders

12. Delete Contacts from "Contact " Folder Automatically

 

 
Powered by phpBB® Forum Software