Outlook 2003 and getting folders with script

T

Tony Murnion

I have a button set up on a custom contact from to add a journal entry for a
contact. It worked fine until I went to Outlook 2003 and now I get the
error because the routine is not able to get the folder name. The following
is the script that I believe is not working correctly. It still works fine
with Outlook 2002

Function GetFolder (pintFolderType, objFolder)
Dim objMyFolders
Dim i
GetFolder = False
Set objMyFolders = Item.Parent.Folders

i = 1
Do While i <= objMyFolders.Count
If objMyFolders.Item(i).DefaultItemType = pintFolderType Then
Set objFolder = objMyFolders.Item(i)
GetFolder = True
Exit Do
End If

i = i + 1
Loop

If Not GetFolder then
MsgBox gstrErrorFolder, vbCritical, gstrAppName
End If
End Function


Thanks in Advance

Tony
 
S

Sue Mosher [MVP-Outlook]

I'm not sure what the purpose of this function is. Why do you believe this
particular function is not working? What error are you seeing?
 
T

Tony Murnion

I inherited these functions and am trying to find the cause of the error
that pops up with 2003. I think this function is designed to get the name
of the folder for the new journal item (there are also buttons for new
contact and email that also do not work). This function gets called and the
parameter passed in the case of a new journal is "olJournalItem" through
pintFolderType variable

I beleive the script is working until this procedure and drops to the last
if statement "if Not GetFolder then" because the message box that pops up
has the error text specified earlier in another part of the script. I'm
wondering if the "Set objMyFolders = Item.Parent.Folders" line is valid. It
does not appear to be finding a match while running through the folders.


Here is more of the script:
Call CreateButton (objCommandBar, "Prospect Journal", 1990, "Create Shared
Journal", False, "cmdJournal_Click")
______________________________
Sub cmdJournal_Click()
Call ButtonClick (olJournalItem)
End Sub
_______________________________
Sub ButtonClick (pintItemType)
Dim objTargetFolder
Dim objNewItem
'Item has to be saved, otherwise linking does not work.
If Item.EntryId = "" then
If MsgBox(gstrErrorButton, vbYesNo + vbQuestion, gstrAppName) = vbYes then
Item.Save
Else
Exit Sub
End if
End If

If GetFolder (pintItemType, objTargetFolder) Then
if pintitemtype <> 2 then
'use folder from getfolder
Else
'set folder to prospects
Set objTargetFolder = Item.parent
End if
etc..................
____________________________________

Thanks

Tony
 
S

Sue Mosher [MVP-Outlook]

I'm wondering if the "Set objMyFolders = Item.Parent.Folders" line is

This statement is always valid.

The problem would seem to be that the item's parent folder has no journal
folders. I presume you're trying to add a journal item to some user-created
folder, rather than the default Journal folder?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
T

Tony Murnion

This is a custom folder for Prospects shared on our Exchange server. We
added a pJournal folder underneath it for shared journals.

I also just found the journal button does function properly on another 2003
machine but that another button similar to this does not.

Both buttons work on a 2002 machine.

Tony

It does work on
 
S

Sue Mosher [MVP-Outlook]

This is a custom folder for Prospects shared on our Exchange server.

Shared in a mailbox or as a public folder?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
T

Tony Murnion

I think as a public folder

Thanks

Tony

Sue Mosher said:
Shared in a mailbox or as a public folder?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

Please check to find out for certain. It makes a difference.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
T

Tony Murnion

I'm not sure how I tell. It is listed under Public Folders in Outlook and
properties show it as a "Folder containing contact items."

I did some further testing. the .count line returns zero. I don't think the
item.parent.folders statement is working correctly on this machine.

Thanks.

Tony Murnion
 
S

Sue Mosher [MVP-Outlook]

If it's in Public Folders, then it's definitely a public folder, not a
mailbox folder.

Are users accessing this folder through the Public Folder\Favorites
hierarchy?

Do they always launch the contact form from the public folder?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

For troubleshooting purposes, can you try it against the non Favorites
folder with an Outlook profile in classic online mode with no offline
folders?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
T

Tony Murnion

I logged into the machine with a local login and set up Outlook using my own
account. Under this scenario, the Public Folder options works like a charm.
Does that mean it is trying to work off the Favorites folder and/or offline
content folder? And what do I do about it?

Thank you.

Tony Murnion
 
S

Sue Mosher [MVP-Outlook]

You'll have to tell us more about how you set up that profile. Is it a
strictly classic online profile?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
T

Tony Murnion

I just let outlook run through the wizard since this was the first time I
set up outlook for this local machine account. I used my domain credentials
for logging into exchange.

Tony
 
S

Sue Mosher [MVP-Outlook]

Then you'll need to look at the profile settings and check. Chances are that
it's in Cached Exchange mode.

Is the error machine-specific or user-specific?
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
T

Tony Murnion

It is in Cached Exchange mode for both the local user and my domain user
account. I cannot change my domain user setup and that is the one that does
not work.

The error is not machine specific and not exactly user specific. It occurs
on my domain login on a machine with Outlook 2003. On the same machine with
the local login I just set up, the error does not occur. I can log into
other machines via the domain and it also works.

Thanks.

Tony
 
Top