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)
Related
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.
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.
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
I'm trying to get all the Deleted Items or Trash folders for all the mail accounts in Outlook. I'm using Outlook Interop in C#, but I can only find the way to get the deleted items folder in the default mail account on MSDN: Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderDeletedItems).
Does anybody know if there is a way that I can get the deleted items folder in every email accounts in Outlook?
Loop through the Namespace.Stores collection and call Store.GetDefaultFolder(olFolderDeletedItems) instead of Namespace.GetDefaultFolder.
In response to the "should work on Outlook 2007" requirement you added in your response to Dmitry's answer, I'd suggest the following approach:
Use a PropertyAccessor to acquire the PR_IPM_WASTEBASKET_ENTRYID ("http://schemas.microsoft.com/mapi/proptag/0x35E30102") of the store
Use PropertyAccessor.BinaryToString to convert it to an EntryID you can use in the COM/interop layer
Use NameSpace.GetItemFromID to access the deleted items folder folder, given it's EntryID and the EntryID of the store.
I would like to acquire all contacts that are shared with the current Outlook user (= acquire all the folders containing contacts that are shared).
It's the kind of sharing where you receive an email invitation from the one who shares the contacts with you. You can then see the folder in your "Persons" tab. The folder is not visible in the "folders" view.
The following link shows a guide on how to reach my goal by enumerating the "nav links" in the elusive "common views" folder and then finally EWS folders via some arcane code.
Sadly, they are using EWS and not the OL interop I am bound to.
I thought I'd get started by acquiring the "Common Views" folder, but I am completely unable to do so. Recursively looking through olApplication.Session.Folders gives me my mailbox and the public folder and their subfolders, but no Common Views folder.
An answer to the following question could probably help me: How do I get a list of recipients whose mailbox I have shared access to via Outlook Interop
I think I could call OpenShared(Default)Folder() with that information.
Any ideas what else I could try?