Advertisement

08.01.2008 at 12:56PM PDT, ID: 23615245
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.1

VBA Outlook Contact Folders

Asked by mike2401 in Outlook Groupware Software, Microsoft Access Database

Tags: , ,

Hello,

I'm using the code sample below to import contacts from Access into Outlook.
This works fine, except it always goes into the main Contacts folder.

I need to specify a different folder of contacts (NOT public folders).  I've created a sub-folder under Contacts called Publishers.  I've also created a folder called Publishers at the same level as the Contacts, Inbox, etc.

I've tried a variations on .folders.item  (array # references), as well as folder names, but can't get it to work.  I've tried things like:
Set cf = olns.GetDefaultFolder(olFolderContacts).Folders.Item(1)
Set cf = olns.GetDefaultFolder(olFolderContacts)
Folders.Item

Any tips would be very much appreciated.  Here's the code sample:

Sub ExportAccessContactsToOutlook()

   'Set up DAO Objects:
   Dim oDataBase As Object
   Dim rst As Object
   Set oDataBase = OpenDatabase _
     ("c:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb")
   Set rst = oDataBase.OpenRecordset("Customers")

   'Set up Outlook Objects:
   Dim olns As Object               ' Outlook Namespace
   Dim cf As Object                 ' Contact folder
   Dim c As Object                  ' Contact Item
   Dim Prop As Object               ' User property
   Dim ol As New Outlook.Application
   Set olns = ol.GetNamespace("MAPI")
   Set cf = olns.GetDefaultFolder(olFolderContacts)

   With rst
      .MoveFirst
      ' Loop through the Access records
      Do While Not .EOF
         ' Create a new Contact item
         Set c = ol.CreateItem(olContactItem)
         ' Specify which Outlook form to use:
         ' Change "IPM.Contact" to "IPM.Contact.<formname>" if you've
         ' created a custom Contact form in Outlook.
         c.MessageClass = "IPM.Contact"
         ' Create all built-in Outlook fields
         If ![CompanyName] <> "" Then c.CompanyName = ![CompanyName]
         If ![ContactName] <> "" Then c.FullName = ![ContactName]
         ' Create the first user property (UserField1)
         Set Prop = c.UserProperties.Add("UserField1", olText)
         ' Set its value
         If ![CustomerID] <> "" Then Prop = ![CustomerID]
         ' Create the second user property (UserField2)
         Set Prop = c.UserProperties.Add("UserField2", olText)
         ' Set it's value, and so on....
         If ![Region] <> "" Then Prop = ![Region]
         ' Save the contact
         c.Save
         .MoveNext
      Loop
   End With
   End Sub
Start Free Trial
[+][-]08.01.2008 at 02:00PM PDT, ID: 22141929

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.01.2008 at 02:02PM PDT, ID: 22141937

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.04.2008 at 06:41AM PDT, ID: 22152311

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.04.2008 at 07:03AM PDT, ID: 22152487

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Outlook Groupware Software, Microsoft Access Database
Tags: Microsoft, Access / Outlook, 2003
Sign Up Now!
Solution Provided By: BlueDevilFan
Participating Experts: 1
Solution Grade: A
 
 
[+][-]08.04.2008 at 07:09AM PDT, ID: 22152548

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.04.2008 at 07:13AM PDT, ID: 22152577

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628