![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Hi,
I have the following code that gets my contacts from outlook and lists then in a listbox on a form to select one. Please advise how i can change the code to get other contacts from a public folder, This is also as a favorite folder in Outlook Thanks in advance Regards Oggy Private Sub UserForm_Initialize() Dim olApp As Outlook.Application Dim oContact As Outlook.ContactItem Dim oContactFolder As Outlook.MAPIFolder Dim oContactItems As Outlook.Items Dim oNS As Outlook.Namespace Dim i As Long Dim j As Long Dim arr() With Me.ComboBox1 .ColumnCount = 3 .ColumnWidths = "175 pt;150 pt;200 pt" .TextColumn = -1 End With On Error GoTo XIT Set olApp = New Outlook.Application Set oNS = olApp.GetNamespace("MAPI") Set oContactFolder = oNS.GetDefaultFolder(olFolderContacts) Set oContactItems = oContactFolder.Items With Me For i = 1 To oContactItems.Count If oContactItems.Item(i).Class = olContact Then Set oContact = oContactItems.Item(i) If oContact.Categories = "Customer " Then j = j + 1 ReDim Preserve arr(0 To 2, 1 To j) With oContact arr(0, j) = .CompanyName arr(1, j) = .FullName arr(2, j) = .BusinessAddress End With End If End If Next i Me.ComboBox1.List() = Application.Transpose(arr) End With XIT: Set oContact = Nothing Set oContactItems = Nothing Set oContactFolder = Nothing Set oNS = Nothing Set olApp = Nothing End Sub |
#2
|
|||
|
|||
![]()
Instead of using Namespace.GetDefaultFolder, you need to drill down the
folder hierarchy starting with the Namespace.Folders collection Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Oggy" wrote in message ups.com... Hi, I have the following code that gets my contacts from outlook and lists then in a listbox on a form to select one. Please advise how i can change the code to get other contacts from a public folder, This is also as a favorite folder in Outlook Thanks in advance Regards Oggy Private Sub UserForm_Initialize() Dim olApp As Outlook.Application Dim oContact As Outlook.ContactItem Dim oContactFolder As Outlook.MAPIFolder Dim oContactItems As Outlook.Items Dim oNS As Outlook.Namespace Dim i As Long Dim j As Long Dim arr() With Me.ComboBox1 .ColumnCount = 3 .ColumnWidths = "175 pt;150 pt;200 pt" .TextColumn = -1 End With On Error GoTo XIT Set olApp = New Outlook.Application Set oNS = olApp.GetNamespace("MAPI") Set oContactFolder = oNS.GetDefaultFolder(olFolderContacts) Set oContactItems = oContactFolder.Items With Me For i = 1 To oContactItems.Count If oContactItems.Item(i).Class = olContact Then Set oContact = oContactItems.Item(i) If oContact.Categories = "Customer " Then j = j + 1 ReDim Preserve arr(0 To 2, 1 To j) With oContact arr(0, j) = .CompanyName arr(1, j) = .FullName arr(2, j) = .BusinessAddress End With End If End If Next i Me.ComboBox1.List() = Application.Transpose(arr) End With XIT: Set oContact = Nothing Set oContactItems = Nothing Set oContactFolder = Nothing Set oNS = Nothing Set olApp = Nothing End Sub |
#3
|
|||
|
|||
![]()
On 22 Mar, 20:34, "Dmitry Streblechenko" wrote:
Instead of using Namespace.GetDefaultFolder, you need to drill down the folder hierarchy starting with the Namespace.Folders collection Dmitry Streblechenko (MVP)http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Oggy" wrote in message ups.com... Hi, I have the following code that gets my contacts from outlook and lists then in a listbox on a form to select one. Please advise how i can change the code to get other contacts from a public folder, This is also as a favorite folder in Outlook Thanks in advance Regards Oggy Private Sub UserForm_Initialize() Dim olApp As Outlook.Application Dim oContact As Outlook.ContactItem Dim oContactFolder As Outlook.MAPIFolder Dim oContactItems As Outlook.Items Dim oNS As Outlook.Namespace Dim i As Long Dim j As Long Dim arr() With Me.ComboBox1 .ColumnCount = 3 .ColumnWidths = "175 pt;150 pt;200 pt" .TextColumn = -1 End With On Error GoTo XIT Set olApp = New Outlook.Application Set oNS = olApp.GetNamespace("MAPI") Set oContactFolder = oNS.GetDefaultFolder(olFolderContacts) Set oContactItems = oContactFolder.Items With Me For i = 1 To oContactItems.Count If oContactItems.Item(i).Class = olContact Then Set oContact = oContactItems.Item(i) If oContact.Categories = "Customer " Then j = j + 1 ReDim Preserve arr(0 To 2, 1 To j) With oContact arr(0, j) = .CompanyName arr(1, j) = .FullName arr(2, j) = .BusinessAddress End With End If End If Next i Me.ComboBox1.List() = Application.Transpose(arr) End With XIT: Set oContact = Nothing Set oContactItems = Nothing Set oContactFolder = Nothing Set oNS = Nothing Set olApp = Nothing End Sub- Hide quoted text - - Show quoted text - The contacts are in the following Public Folders\Favorites\Oggy Contacts I have Tried the following code but to no avail, On Error GoTo XIT Set olApp = New Outlook.Application Set oNS = olApp.GetNamespace("MAPI") Set oContactFolder = oNS.GetPublicFoldersFavoritesOggyContacts(olFolder Contacts) Set oContactItems = oContactFolder.Items Thanks for your input Oggy |
#4
|
|||
|
|||
![]()
Set oContactFolder = oNS.Folders("Public
Folders").Folders("Favorites").Folders("Oggy Contacts") Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Oggy" wrote in message oups.com... On 22 Mar, 20:34, "Dmitry Streblechenko" wrote: Instead of using Namespace.GetDefaultFolder, you need to drill down the folder hierarchy starting with the Namespace.Folders collection Dmitry Streblechenko (MVP)http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Oggy" wrote in message ups.com... Hi, I have the following code that gets my contacts from outlook and lists then in a listbox on a form to select one. Please advise how i can change the code to get other contacts from a public folder, This is also as a favorite folder in Outlook Thanks in advance Regards Oggy Private Sub UserForm_Initialize() Dim olApp As Outlook.Application Dim oContact As Outlook.ContactItem Dim oContactFolder As Outlook.MAPIFolder Dim oContactItems As Outlook.Items Dim oNS As Outlook.Namespace Dim i As Long Dim j As Long Dim arr() With Me.ComboBox1 .ColumnCount = 3 .ColumnWidths = "175 pt;150 pt;200 pt" .TextColumn = -1 End With On Error GoTo XIT Set olApp = New Outlook.Application Set oNS = olApp.GetNamespace("MAPI") Set oContactFolder = oNS.GetDefaultFolder(olFolderContacts) Set oContactItems = oContactFolder.Items With Me For i = 1 To oContactItems.Count If oContactItems.Item(i).Class = olContact Then Set oContact = oContactItems.Item(i) If oContact.Categories = "Customer " Then j = j + 1 ReDim Preserve arr(0 To 2, 1 To j) With oContact arr(0, j) = .CompanyName arr(1, j) = .FullName arr(2, j) = .BusinessAddress End With End If End If Next i Me.ComboBox1.List() = Application.Transpose(arr) End With XIT: Set oContact = Nothing Set oContactItems = Nothing Set oContactFolder = Nothing Set oNS = Nothing Set olApp = Nothing End Sub- Hide quoted text - - Show quoted text - The contacts are in the following Public Folders\Favorites\Oggy Contacts I have Tried the following code but to no avail, On Error GoTo XIT Set olApp = New Outlook.Application Set oNS = olApp.GetNamespace("MAPI") Set oContactFolder = oNS.GetPublicFoldersFavoritesOggyContacts(olFolder Contacts) Set oContactItems = oContactFolder.Items Thanks for your input Oggy |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Public folder contacts | JeffH13 | Outlook - Using Contacts | 2 | January 25th 07 09:31 PM |
How do I copy a contacts folder into one in a public folder | Shona | Outlook - Using Contacts | 4 | September 1st 06 03:15 PM |
Can I combine shared contacts and make a public folder of contacts | Nicole | Outlook - Using Contacts | 4 | August 10th 06 05:36 PM |
Show Public Folder Contacts in Contacts | [email protected] | Outlook - Using Contacts | 3 | June 5th 06 01:52 AM |
Making the Public Folder Contacts the Primary Contacts?? | Roman B. | Outlook - Using Contacts | 1 | January 9th 06 11:52 AM |