Accessing another user's custom Calendar programatically - c#

I am working on an outlook plugin. I want to give my manager reviewer permission to see my custom calendar (not the main Outlook Calendar) which I create programmatically.
My manager should be able to view my custom calendar programmatically.
I have given reviewer permission to my manager.
As of now, I don't know of any way where he can directly access my custom calendar programmatically. My custom calendar is at the same level as the main calendar.
A code like the following will not solve my purpose.
Outlook.Recipient oRecip = (Outlook.Recipient)oNS.CreateRecipient(userName);
Outlook.MAPIFolder usersCalendarFolder =
(Outlook.MAPIFolder) oNS.GetSharedDefaultFolder(oRecip,
Outlook.OlDefaultFolders.olFolderCalendar)
As this is to get my root calendar only.
And I dont want to give reviewer permission on my root folder. i.e. just "reviewer" permission on the custom calendar.
Do we have a way to achieve what I need?

Only Outlook's default folders for each item type can be accessed using GetSharedDefaultFolder. If you need to share any other folder that you've created manually, you'll have to share your entire Mailbox so that they can open it as an additional Mailbox in their Outlook profile or add it as a separate account.

Related

Is there a way of sending emails by a second account which is only shared with Outlook Interop Library?

Is there a way where we could send E-Mail's via the Microsoft Interop Outlook Library by using the second mail like in this picture?
Whenever I tried sending E-Mails by the second folder, it uses the standard folder.
_Outlook.Folder folder = (_Outlook.Folder)outlookApp.ActiveExplorer().Session.Folders[1];
_Outlook.AppointmentItem agendaMeeting = (_Outlook.AppointmentItem)folder.Application.CreateItem(_Outlook.OlItemType.olAppointmentItem);
Firstly, do not hardcode the indices (e.g. Session.Folders[1]) - retrieve the stores by name.
If you already have MAPIFolder, call MAPIFolder.Items.Add instead of Application.CreateItem
You need to use the Items collections of the folder (Calendar folder in our case), not Application. The Add method accepts the OlItemType enumeration too and returns a newly created Outlook item.
_Outlook.AppointmentItem agendaMeeting = (_Outlook.AppointmentItem)folder.Application.CreateItem(_Outlook.OlItemType.olAppointmentItem);
Read more about possible ways of creating calendar items in the How To: Create a new Outlook Appointment item article.

Get Outlook Shared Calendar without Delegation VBA/C#

As the GetSharedDefaultFolder method description states:
This method is used in a delegation scenario, where one user has delegated access to another user for one or more of their default folders (for example, their shared Calendar folder).
Is there a way to get shared calendar appointment items without being a delegate of the person?
For example, I could do an File -> Open -> Open User's Folder to see people's busy/free status for about anyone or mail box. But apparently this permission level won't enable the GetSharedDefaultFolder() method.
You can use Recipient.GetFreeBusy or AddressEntry.FreeBusy in this scenario.

How to get actual list of Outlook accounts in Add-In after adding or removing an account by user?

My Add-In should change its mode if the list of accounts is changed.
I get the list of outlook accounts the following way:
var ns = application.GetNamespace("MAPI");
accounts = ns.Accounts;
It works, but when user adds new account or remove some of them, the ns.Accounts still shows old value. It's changed only if I reload outlook.
Also I have been searching events for adding and removing accounts and still can't find.
Could you please help me?
There are no events that occur in the Outlook Object Model when accounts are modified. You have to restart Outlook in order to see the changes. The only other related option is to monitor the Stores.StoreAdd event if the user opens or adds a Data File to the profile, but that's probably not useful for your needs.
Otherwise you can use a third-party library like Redemption, which can monitor changes to Accounts: http://www.dimastr.com/redemption/RDOAccounts.htm#events

Outlook Interop Accessing Deleted Item Folder from Shared Calendar

Consider the following scenario:
Sombody shared a calendar with me. I have full access to this calendar. When i delete an Item in the calendar the Folder.BeforeItemMove Event is fired. So far so good.
I want to Track deletion by check wether the MoveTo Entry id is null or the Entry id of the Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems) which works.
Now back to the case where the item is in a shared folder:
As per documentation the Property olFolderDeletedItems is a no go as parameter for GetSharedDefaultFolders() (Just to be sure i accessed the other folders which were allowed which worked)
I tried to Iterate over the Stores collection. No calendar there
I tried to Access the Store Property on the MoveTo folder -> null
I tried to get the Store from the Session (to inspect the PR_IPM_WASTEBASKET_ENTRYID) -> Fails
I CAN get the folder name Problem with this is , it might be renamed and/or localized and i do not want an array with all the deleted folder names floating around if i can't help it
I tested all of this using either plain OOM or redemptions Folder interface
Any Ideas?
(Tested in Outlook 2016)
RDOStore.GetDefaultFolder(olFolderDeletedItems) and RDOSession.GetSharedDefaultFolder(olFolderDeletedItems) both work in Redemption.
If you have access to the Calendar as a Shared Calendar (e.g. Sent as EMail invitation to you via the OWA) deleted Items go to YOUR deleted items Folder. This you can get via
Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems)
If the Calendar is in a second mailbox in your profile the deleted item go to the deleted items folder of THAT account which you can acces via
Outlook.Store _Store = MoveTo.Store;
Outlook.Folder _Folder = MoveTo.GetDefaultFolder (OlDefaultFolders.olFolderDeletedItems) as Outlook.Folder;
You can differntiate these two scenarios by Checking if the Folder.Store is null (which it is in the case of an Shared non mailbox calendar)

Add .ics file to outlook without the user downloading it

I am writing an ASP.NET webapp together with some other students. We have to make it possible to schedule an appointment in outlook. So far we were able to create a .ics file with the dday iCalendar library. the user can download it and add it to outlook. is there a way to add the ics immediatly to the outlook calender withouth the user forcing to download it?
Yes, if the user is using IE and you site is added to the list of trusted sites. If these conditions are met, you can use the Outlook Object Model from your client side Java Script to create an instance of the Outlook.Application object using new ActiveXObject('Outlook.Application'). You can then call Application.CreateItem(1) (1 stands for the olAppointmentItem enum). Populate all the AppointmentItem properties and call AppointmentItem.Save.

Categories

Resources