I am developing Outlook add-ins which populates all the available shared mailboxes in to combo box and sends email using the selected mailbox.
When I select the mail account from combo box, I get error
Unable to cast object of type 'System.String' to type 'Microsoft.Office.Interop.Outlook.Store'
Following is the code. Populate combo box.
private void MailBoxOptions_Load(object sender, EventArgs e)
{
Microsoft.Office.Interop.Outlook.Application application =
new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.NameSpace ns = application.GetNamespace("MAPI");
Stores stores = ns.Stores;
foreach (var store in Globals.ThisAddIn.Application.Session.Stores
.Cast()
.Where(c => c.ExchangeStoreType ==
Microsoft.Office.Interop.Outlook.OlExchangeStoreType.olExchangeMailbox))
{
if (store != null)
{
mailBoxes.Items.Add(store.DisplayName);
}
else
{
MessageBox.Show("You don't have access to any shared mail-inbox.");
}
}
}
Code for Combo box
public void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
var selectedStore = (Store)mailBoxes.SelectedItem;
}
Any help would be appreciated. Thanks.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)