I'm doing a plugin for outlook, but when I try to get the namespaces for calendars, I get this error: https://i.stack.imgur.com/ZV6eN.png
So, in some computers not happen, but when another person try to install this error its showed, my code that break the app is this:
private async void AddinModule_AddinInitialize(object sender, EventArgs e)
{
try
{
var app = this.OutlookApp;
Outlook.NameSpace nameSpace = app.GetNamespace("MAPI");
foreach (Outlook.Store store in nameSpace.Stores)
{
if (store.IsCachedExchange)
{
calendarFolders.Add(store.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar));
}
}
await updateAppItemList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error CODE 0x01", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private Task updateAppItemList()
{
appItems = new List<Outlook.AppointmentItem>();
foreach (Outlook.MAPIFolder folder in calendarFolders)
{
Outlook.Items items = folder.Items;
var parent = items.Parent as Outlook.MAPIFolder;
if (!calendarItems.Any(x => (x.Parent as Outlook.MAPIFolder).StoreID == folder.StoreID))
{
items.ItemAdd += this.ItemAdd;
items.ItemChange += this.ItemChange;
calendarItems.Add(items);
}
foreach (var item in items)
{
Outlook.AppointmentItem appItem = item as Outlook.AppointmentItem;
if (appItem != null)
{
appItem.BeforeDelete += this.ItemRemove;
appItems.Add(appItem);
}
}
}
return Task.FromResult(0);
}