Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GetSharedDefaultFolder woes

174 views
Skip to first unread message

Mark Smith

unread,
Mar 31, 2006, 11:56:06 AM3/31/06
to
I have been trying to figure out a problem with using GetSharedDefaultFolder
and I'm stuck.

I am using Outlook 2003 sp3 connected to Exchange Server 2003. This problem
also shows up using Outlook 2003 sp2. Other configurations have not been
tested yet.

I am using C++, but I have been getting the same results running this simple
script from the script editor in OutlookSpy, as suggested by Dimitry in some
another post regarding GetSharedDefaultFolder:

Set NS = Application.GetNamespace("MAPI")
Set Recip = NS.CreateRecipient("A")
Recip.Resolve()
set Folder = NS.GetSharedDefaultFolder(Recip, olFolderCalendar)
MsgBox Folder.Items.Count

The GetSharedDefaultFolder call throws an exception. For this user, the
exception is "Outlook does not recognize one or more names.". For some
users, I get "The operation failed.". It works fine for other users.

According to many posts I have seen, the Recip.Resolve() call is not
necessary (and annoying, since it causes the dreaded security prompt!), so I
tried removing that, but the result is the same.

One thing I noticed is that the cases that fail are those where the user
starts with the same letter as another user. This is not one-hundred
percent true, but there seems to be a strong correlation. For example, I
have only one user that starts with "B", and it works just fine, but any of
the users that start with "A" fail with one exception or the other.

Any suggestions? I can use MAPI if that is the only way around this, but I
haven't been able to find any information on replacing OOM
GetSharedDefaultFolder calls with MAPI.

Thanks,
Mark Smith


Dmitry Streblechenko

unread,
Mar 31, 2006, 1:47:42 PM3/31/06
to
This simply means that the name is ambiguous - you need to make sure that
you pass a name that can be *uniquely* resolved to a given user. One of the
proxy SMTP addresses would do (e.g. "A.U...@mycompany.com"). If you do call
Recipient.Resolve, also make sure that you check th Recipient.Resolved
property afterwards.
On the MAPI level, Outlook uses IExchangeManageStore to open ImshStore of
another user, read the default folder's entry id from the root folder, then
open the default foler.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mark Smith" <i...@online.nospam> wrote in message
news:%23sr7BQO...@TK2MSFTNGP12.phx.gbl...

Mark Smith

unread,
Mar 31, 2006, 3:57:04 PM3/31/06
to
By that do you mean, PR_EMS_AB_PROXY_ADDRESSES?

Thanks a lot!
Mark

"Dmitry Streblechenko" <dmi...@dimastr.com> wrote in message
news:%23qLlUNP...@TK2MSFTNGP14.phx.gbl...

Dmitry Streblechenko

unread,
Mar 31, 2006, 4:24:09 PM3/31/06
to
Yep, one of those should work - you can see them on the "Email addresses"
tab of the GAL entry dialog.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mark Smith" <i...@online.nospam> wrote in message

news:O$KEtWQVG...@TK2MSFTNGP14.phx.gbl...

Mark Smith

unread,
Apr 3, 2006, 11:34:15 AM4/3/06
to
Strange. I would have thought that the user name would be unique.

Is the proxy SMTP address always guaranteed to be there? If not, is there
another way that will always work?

Mark

"Dmitry Streblechenko" <dmi...@dimastr.com> wrote in message
news:%23qLlUNP...@TK2MSFTNGP14.phx.gbl...

Dmitry Streblechenko

unread,
Apr 3, 2006, 2:27:34 PM4/3/06
to
They *are* unique, but Outlook matches based on the name prefix: e.g. if you
have a user named "admin" and "administrator", you will get an ambiguous
name error if specify "admin" since it matches both users.
Try to specify the names in either "name@" or "=name" form.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mark Smith" <i...@online.nospam> wrote in message

news:u0hxSQzV...@TK2MSFTNGP12.phx.gbl...

Mark Smith

unread,
Apr 13, 2006, 10:24:32 AM4/13/06
to
This seems to be working fine in most cases, but we have one case that still
doesn't work. I have not been able to duplicate this on other computers
with the same configuration. The computer is running OL 2003 SP2 connected
to Exchange 2003. On this computer, the GetSharedDefaultFolder call works
great with cached mode off. With cached mode on, the call works fine for
most users, but for a few of them it doesn't. I get the same error message:
"Outlook does not recognize one or more names". I tested using the sample
VB script in OutlookSpy and got the same result. I am using the "=name"
form, if that matters. I could try using the SMTP address form if
necessary, but that takes a lot more work than just tacking on an equals
sign.

Any ideas?

Mark

"Dmitry Streblechenko" <dmi...@dimastr.com> wrote in message

news:u8A4Cw0V...@TK2MSFTNGP15.phx.gbl...

Dmitry Streblechenko

unread,
Apr 13, 2006, 1:06:03 PM4/13/06
to
Does the same thing happen if you type that name in the To edit in Outlook
and hit Ctrl+K?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mark Smith" <s...@nospam.nospam> wrote in message
news:e5np%23XwXG...@TK2MSFTNGP03.phx.gbl...

Mark Smith

unread,
Apr 13, 2006, 4:00:38 PM4/13/06
to
No. That works as expected on both computers I am testing with. When
typing "a" and pressing Ctrl+K, a dialog pops up saying multiple users were
found. When typing "=a" and pressing Ctrl+K, the name resolves correctly.

Mark


"Dmitry Streblechenko" <dmi...@dimastr.com> wrote in message

news:%23OYDExx...@TK2MSFTNGP04.phx.gbl...

Mark Smith

unread,
Apr 17, 2006, 10:18:33 AM4/17/06
to
Any other ideas?

Mark

"Mark Smith" <s...@nospam.nospam> wrote in message

news:O7bxwTzX...@TK2MSFTNGP03.phx.gbl...

Dmitry Streblechenko

unread,
Apr 17, 2006, 1:30:51 PM4/17/06
to
Did you try to use the SMTP or EX address instead? Where does the user name
come from?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mark Smith" <s...@nospam.nospam> wrote in message

news:uwyBRniY...@TK2MSFTNGP05.phx.gbl...

Mark Smith

unread,
Apr 18, 2006, 2:26:04 PM4/18/06
to
Yes, this works, at least in the test script. I haven't yet implemented in
our code. Do you have any idea why the "=" version isn't working?

The only problem with doing the SMTP lookup is then I have to do a MAPI
logon, which won't work if the default e-mail client isn't Outlook. Or is
there a way to get to the current MAPI session through OOM?

Mark

"Dmitry Streblechenko" <dmi...@dimastr.com> wrote in message

news:elp7jRk...@TK2MSFTNGP02.phx.gbl...

Dmitry Streblechenko

unread,
Apr 18, 2006, 5:44:02 PM4/18/06
to
You can get IMAPISession from Namespace.MAPIOJBECT, but I am not sure why
you need that - EX address would work just fine. If you already have a
Recipient or AddressEntry object, just use the Address property.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mark Smith" <s...@nospam.nospam> wrote in message

news:uOIhPWxY...@TK2MSFTNGP05.phx.gbl...

Dmitry Streblechenko

unread,
Apr 18, 2006, 8:09:24 PM4/18/06
to
Oh, and it is hard to say why "=" does not work: I'd need to see the Outlook
source code for that :-)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mark Smith" <s...@nospam.nospam> wrote in message

news:uOIhPWxY...@TK2MSFTNGP05.phx.gbl...

gledhi...@gmail.com

unread,
Oct 2, 2013, 8:01:13 AM10/2/13
to
On Friday, March 31, 2006 8:47:42 PM UTC+2, Dmitry Streblechenko wrote:
> This simply means that the name is ambiguous - you need to make sure that
> you pass a name that can be *uniquely* resolved to a given user.


(7 years later..)

I have had the same issue today. My call to GetSharedDefaultFolder() was failing, even though I had a valid Exchange user name, which Resolved into exactly one Exchange user.

The fix was to change my code to Resolve using the (same user's) SMTP email address instead of their recognised Exchange name.

Then, the Resolve() still worked, but fetching that user's Shared Calendar did succeed.


Recipient recip = this.Application.ActiveExplorer().Session. CreateRecipient(calendarOwnerEmail);

recip.Resolve();

folder = Globals.ThisAddIn.Application.Session.GetSharedDefaultFolder(recip, OlDefaultFolders.olFolderCalendar) as Outlook.Folder;


0 new messages