A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

public folders



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 26th 06, 11:05 PM posted to microsoft.public.outlook.program_vba
apple
external usenet poster
 
Posts: 5
Default public folders

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  
Old November 26th 06, 11:39 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default public folders

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  
Old November 27th 06, 05:40 AM posted to microsoft.public.outlook.program_vba
apple
external usenet poster
 
Posts: 5
Default public folders



"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  
Old November 27th 06, 12:22 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default public folders

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  
Old November 27th 06, 02:42 PM posted to microsoft.public.outlook.program_vba
apple
external usenet poster
 
Posts: 5
Default public folders

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  
Old November 27th 06, 02:53 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default public folders

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  
Old November 27th 06, 11:21 PM posted to microsoft.public.outlook.program_vba
apple
external usenet poster
 
Posts: 5
Default public folders

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  
Old November 27th 06, 11:33 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default public folders

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  
Old November 28th 06, 01:14 AM posted to microsoft.public.outlook.program_vba
apple
external usenet poster
 
Posts: 5
Default public folders

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
Search this Thread:

Advanced Search
Display Modes

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
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 03:47 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.