![]() |
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
|
|||
|
|||
![]()
I am using VBA in Access 2003 and would like to edit Contacts in the Public
Folders. The code works fine for the Default Contacts, but when accessing Contacts with in the Public Folders it fails. It appears the object, item, is a 'Post' item instead of a 'Contact' item. Thanks in advance... Jack |
Ads |
#2
|
|||
|
|||
![]()
What code? What indication do you have that it's a PostItem?
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "apple" wrote in message ... I am using VBA in Access 2003 and would like to edit Contacts in the Public Folders. The code works fine for the Default Contacts, but when accessing Contacts with in the Public Folders it fails. It appears the object, item, is a 'Post' item instead of a 'Contact' item. Thanks in advance... Jack |
#3
|
|||
|
|||
![]() "apple" wrote: I am using VBA in Access 2003 and would like to edit Contacts in the Public Folders. The code works fine for the Default Contacts, but when accessing Contacts with in the Public Folders it fails. It appears the object, item, is a 'Post' item instead of a 'Contact' item. Thanks in advance... Jack I am checking the item class. When it works the class is '40' which is a Contact item. In this case when it does not work the class is '45' which is a Post item. |
#4
|
|||
|
|||
![]()
So, did you look at the actual item? Maybe the folder really does contain a stray PostItem.
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "apple" wrote in message ... "apple" wrote: I am using VBA in Access 2003 and would like to edit Contacts in the Public Folders. The code works fine for the Default Contacts, but when accessing Contacts with in the Public Folders it fails. It appears the object, item, is a 'Post' item instead of a 'Contact' item. Thanks in advance... Jack I am checking the item class. When it works the class is '40' which is a Contact item. In this case when it does not work the class is '45' which is a Post item. |
#5
|
|||
|
|||
![]()
The items in the Contact look normal. This problem seems to also occur in
any Contact Folder that is a Sub-Folder. I quess my question is: Is it possible to edit Contacts in sub-folders, public folders, and sub-folders within public folders using VBA code? "Sue Mosher [MVP-Outlook]" wrote: So, did you look at the actual item? Maybe the folder really does contain a stray PostItem. -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "apple" wrote in message ... "apple" wrote: I am using VBA in Access 2003 and would like to edit Contacts in the Public Folders. The code works fine for the Default Contacts, but when accessing Contacts with in the Public Folders it fails. It appears the object, item, is a 'Post' item instead of a 'Contact' item. Thanks in advance... Jack I am checking the item class. When it works the class is '40' which is a Contact item. In this case when it does not work the class is '45' which is a Post item. |
#6
|
|||
|
|||
![]()
Is it
possible to edit Contacts in sub-folders, public folders, and sub-folders within public folders using VBA code? Certainly, as long as the current user has the appropriate permission on the folder. Maybe it's time you showed a code snippet? -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "apple" wrote in message ... The items in the Contact look normal. This problem seems to also occur in any Contact Folder that is a Sub-Folder. I quess my question is: Is it possible to edit Contacts in sub-folders, public folders, and sub-folders within public folders using VBA code? "Sue Mosher [MVP-Outlook]" wrote: So, did you look at the actual item? Maybe the folder really does contain a stray PostItem. "apple" wrote in message ... "apple" wrote: I am using VBA in Access 2003 and would like to edit Contacts in the Public Folders. The code works fine for the Default Contacts, but when accessing Contacts with in the Public Folders it fails. It appears the object, item, is a 'Post' item instead of a 'Contact' item. Thanks in advance... Jack I am checking the item class. When it works the class is '40' which is a Contact item. In this case when it does not work the class is '45' which is a Post item. |
#7
|
|||
|
|||
![]()
Sue, here is the code:
Option Compare Database Function FixOutlookContactsjfl() Dim MyFolder As Outlook.MAPIFolder Dim MyItems As Outlook.Items Dim MyItem As Object 'Set MyFolder = Outlook.Application.GetNamespace("MAPI").Folders(" Mailbox - Neel Sus").Folders("SageCRM") 'Set MyFolder = Outlook.Application.GetNamespace("MAPI").Folders(" Public Folders").Folders("All Public Folders").Folders("TheOlingerGroup Contacts") Set MyFolder = Outlook.Application.GetNamespace("MAPI").GetDefaul tFolder(olFolderContacts) 'Set MyFolder = Outlook.Application.GetNamespace("MAPI").PickFolde r MsgBox "MyFolder: " & " " & str(MyFolder.Class) Set MyItems = MyFolder.Items 'If MyItems.Class = olItemProperties Then 'MsgBox "TEST" & " - " '& MyItem.FirstName 'End If MsgBox "MyItems: " & " " & str(MyItems.Class) i = MyItems.Count For Each MyItem In MyItems MsgBox "MyItem: " & " " & str(MyItem.Class) 'If Len(MyItem.Email1Address) = 0 Then 'Else MyItem.Email1DisplayName = MyItem.FirstName & " " & MyItem.LastName & " (" & MyItem.Email1Address & ")" 'MyItem.Save End 'End If Next Set MyItem = Nothing Set MyItems = Nothing Set MyFolder = Nothing End Function -------------------------------------------------------------- "Sue Mosher [MVP-Outlook]" wrote: What code? What indication do you have that it's a PostItem? -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "apple" wrote in message ... I am using VBA in Access 2003 and would like to edit Contacts in the Public Folders. The code works fine for the Default Contacts, but when accessing Contacts with in the Public Folders it fails. It appears the object, item, is a 'Post' item instead of a 'Contact' item. Thanks in advance... Jack |
#8
|
|||
|
|||
![]()
Taking out all the comments, below is what I get. myItem.Save was commented out.
Set MyFolder = Outlook.Application.GetNamespace("MAPI").GetDefaul tFolder(olFolderContacts) Set MyItems = MyFolder.Items For Each MyItem In MyItems MsgBox "MyItem: " & " " & str(MyItem.Class) MyItem.Email1DisplayName = MyItem.FirstName & " " & MyItem.LastName & " (" & MyItem.Email1Address & ")" End Next The right way to iterate a contacts folder needs to involve a more robust check for Class: On Error Resume Next For Each MyItem in MyItems If myItem.Class = olContact Then MyItem.Email1DisplayName = MyItem.FirstName & " " & MyItem.LastName & " (" & MyItem.Email1Address & ")" MyItem.Save End If Next Even if an item "looks normal," it still could be a PostItem if the custom form was designed to look like a contact. -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "apple" wrote in message ... Sue, here is the code: Option Compare Database Function FixOutlookContactsjfl() Dim MyFolder As Outlook.MAPIFolder Dim MyItems As Outlook.Items Dim MyItem As Object 'Set MyFolder = Outlook.Application.GetNamespace("MAPI").Folders(" Mailbox - Neel Sus").Folders("SageCRM") 'Set MyFolder = Outlook.Application.GetNamespace("MAPI").Folders(" Public Folders").Folders("All Public Folders").Folders("TheOlingerGroup Contacts") Set MyFolder = Outlook.Application.GetNamespace("MAPI").GetDefaul tFolder(olFolderContacts) 'Set MyFolder = Outlook.Application.GetNamespace("MAPI").PickFolde r MsgBox "MyFolder: " & " " & str(MyFolder.Class) Set MyItems = MyFolder.Items 'If MyItems.Class = olItemProperties Then 'MsgBox "TEST" & " - " '& MyItem.FirstName 'End If MsgBox "MyItems: " & " " & str(MyItems.Class) i = MyItems.Count For Each MyItem In MyItems MsgBox "MyItem: " & " " & str(MyItem.Class) 'If Len(MyItem.Email1Address) = 0 Then 'Else MyItem.Email1DisplayName = MyItem.FirstName & " " & MyItem.LastName & " (" & MyItem.Email1Address & ")" 'MyItem.Save End 'End If Next Set MyItem = Nothing Set MyItems = Nothing Set MyFolder = Nothing End Function -------------------------------------------------------------- "Sue Mosher [MVP-Outlook]" wrote: What code? What indication do you have that it's a PostItem? -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "apple" wrote in message ... I am using VBA in Access 2003 and would like to edit Contacts in the Public Folders. The code works fine for the Default Contacts, but when accessing Contacts with in the Public Folders it fails. It appears the object, item, is a 'Post' item instead of a 'Contact' item. Thanks in advance... Jack |
#9
|
|||
|
|||
![]()
Thanks! I'll get to work on it and let you know.
"Sue Mosher [MVP-Outlook]" wrote: Taking out all the comments, below is what I get. myItem.Save was commented out. Set MyFolder = Outlook.Application.GetNamespace("MAPI").GetDefaul tFolder(olFolderContacts) Set MyItems = MyFolder.Items For Each MyItem In MyItems MsgBox "MyItem: " & " " & str(MyItem.Class) MyItem.Email1DisplayName = MyItem.FirstName & " " & MyItem.LastName & " (" & MyItem.Email1Address & ")" End Next The right way to iterate a contacts folder needs to involve a more robust check for Class: On Error Resume Next For Each MyItem in MyItems If myItem.Class = olContact Then MyItem.Email1DisplayName = MyItem.FirstName & " " & MyItem.LastName & " (" & MyItem.Email1Address & ")" MyItem.Save End If Next Even if an item "looks normal," it still could be a PostItem if the custom form was designed to look like a contact. -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "apple" wrote in message ... Sue, here is the code: Option Compare Database Function FixOutlookContactsjfl() Dim MyFolder As Outlook.MAPIFolder Dim MyItems As Outlook.Items Dim MyItem As Object 'Set MyFolder = Outlook.Application.GetNamespace("MAPI").Folders(" Mailbox - Neel Sus").Folders("SageCRM") 'Set MyFolder = Outlook.Application.GetNamespace("MAPI").Folders(" Public Folders").Folders("All Public Folders").Folders("TheOlingerGroup Contacts") Set MyFolder = Outlook.Application.GetNamespace("MAPI").GetDefaul tFolder(olFolderContacts) 'Set MyFolder = Outlook.Application.GetNamespace("MAPI").PickFolde r MsgBox "MyFolder: " & " " & str(MyFolder.Class) Set MyItems = MyFolder.Items 'If MyItems.Class = olItemProperties Then 'MsgBox "TEST" & " - " '& MyItem.FirstName 'End If MsgBox "MyItems: " & " " & str(MyItems.Class) i = MyItems.Count For Each MyItem In MyItems MsgBox "MyItem: " & " " & str(MyItem.Class) 'If Len(MyItem.Email1Address) = 0 Then 'Else MyItem.Email1DisplayName = MyItem.FirstName & " " & MyItem.LastName & " (" & MyItem.Email1Address & ")" 'MyItem.Save End 'End If Next Set MyItem = Nothing Set MyItems = Nothing Set MyFolder = Nothing End Function -------------------------------------------------------------- "Sue Mosher [MVP-Outlook]" wrote: What code? What indication do you have that it's a PostItem? -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "apple" wrote in message ... I am using VBA in Access 2003 and would like to edit Contacts in the Public Folders. The code works fine for the Default Contacts, but when accessing Contacts with in the Public Folders it fails. It appears the object, item, is a 'Post' item instead of a 'Contact' item. Thanks in advance... Jack |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Search in sub-folders in Public Folders | Nicolas Macarez | Outlook - General Queries | 3 | November 9th 06 09:46 AM |
OL2k3 Automatically Adding Public Folders to 'Favorite Folders' list in Mail | Ben | Outlook - General Queries | 0 | October 4th 06 04:19 PM |
How do I configure Public Folders to be default contact folders? | RobinBaral | Outlook - Using Contacts | 2 | September 27th 06 04:12 PM |
Is there a way to display Public Folders in the All Mail Folders view? Outlook2003 | Cappy | Outlook - General Queries | 1 | July 20th 06 02:20 AM |
Is there a way to display Public Folders in the All Mail Folders view? Outlook2003 | Cappy | Outlook - Installation | 1 | July 20th 06 02:20 AM |