[Outlook] Display of shared calendar shows "Cannot display the folder"

Add-in Express™ Support Service
That's what is more important than anything else

[Outlook] Display of shared calendar shows "Cannot display the folder"
 
Arkadius




Posts: 30
Joined: 2012-08-21
Hi,

I try to display shared calendars. I use GetSharedDefaultFolder from the Namespace class using the following code:

Outlook.NameSpace ns = null;
Outlook.Recipient rec = null;

try
{
    ns = this.OutlookApp.GetNamespace("MAPI");
    rec = ns.CreateRecipient("Name");

    if (rec.Resolve())
    {
        Outlook.MAPIFolder folder = null;

        try
        {
            folder = ns.GetSharedDefaultFolder(rec, Outlook.OlDefaultFolders.olFolderCalendar);
            folder.Display();
        }
        finally
        {
            if (folder != null)
                Marshal.ReleaseComObject(folder);
        }
    }
}
finally
{
    if (ns != null)
        Marshal.ReleaseComObject(ns);

    if (rec != null)
        Marshal.ReleaseComObject(rec);
}


Source: http://msdn.microsoft.com/en-us/library/ff184606.aspx

The opened windows shows always "Cannot display the folder.". But when I open it manually using "File -> Open -> Other User's Folder .." then it works!

User added an image

Do you have any idea what the problem could be?

Best regards,
Arkadius
Posted 16 Jan, 2013 09:05:16 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hi Arkadius,

Please check if your code produces an exception. I'd also check if the same occurs in VBA, see also http://social.msdn.microsoft.com/Forums/da-DK/outlookdev/thread/79a35956-3469-4da7-984c-4abf7f22dd88.


Andrei Smolin
Add-in Express Team Leader
Posted 16 Jan, 2013 10:20:17 Top
Arkadius




Posts: 30
Joined: 2012-08-21
Hi Andrei,

the code doesn't produce any exceptions.

I also tested it in VBA with the following code:

Sub test()
    Dim ns As Outlook.NameSpace
    Dim rec As Outlook.Recipient

    Set ns = Application.GetNamespace("MAPI")
    Set rec = ns.CreateRecipient("Name")
    
    If rec.Resolve() Then
        Dim folder As Outlook.folder
        Set folder = ns.GetSharedDefaultFolder(rec, olFolderCalendar)
        folder.Display
    End If
End Sub


But I still get the same result!

Do you have any more ideas? :)

Best regards,
Arkadius
Posted 21 Jan, 2013 09:37:36 Top
Arkadius




Posts: 30
Joined: 2012-08-21
I got it! It seems to be a permission problem!

I simply changed the user to resolve and it works.

Best regards,
Arkadius
Posted 21 Jan, 2013 09:53:13 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Great!


Andrei Smolin
Add-in Express Team Leader
Posted 21 Jan, 2013 10:07:11 Top