I am trying to send an email from the Outlook COM object but from an 'Account' that is not my main account. I have tried to search through my accounts, but it only list 1 account and it always sends only from that account. The other account I am trying to send from is a shared mailbox eg a folder. I am able to go to the mailbox and reply to a message in Outlook and it gives the correct email from, but in the program it only gives my standard from.
Microsoft.Office.Interop.Outlook.Application oApp = new
Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItemFromTemplate("c:\\test\\CAEmail.oft", inbox);
Outlook.Accounts accounts = oApp.Session.Accounts;
foreach (Outlook.Account account in accounts)
{
oMsg.Subject = subj;
oMsg.HTMLBody = message;
oMsg.To = emailTo;
oMsg.SendUsingAccount = account;
oMsg.Send();
}