In my Outlook Addin, I need to know if the Sender email adddress in the From field is a type of shared mailbox email address before allowing the email to be sent out. Currently, I'm checking that if the sender address doesn't exist in one of the current sessions' accounts' email address, I would assume it as a shared mailbox email address because it is not possible for a person to login to Outlook using a shared mailbox email address.
However, this logic is flawed because non-shared mailbox email address can also be set in the From field (Correct me if I'm wrong).
Here is my code:
public bool isSharedMailboxAccount(Microsoft.Office.Interop.Outlook.MailItem mail)
{
string fromEmail = mail.Sender.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x39FE001E").ToString();
bool isShared = true;
foreach (Microsoft.Office.Interop.Outlook.Account acc in mail.Session.Accounts)
{
if (acc.SmtpAddress == fromEmail)
{
isShared = false;
break;
}
}
return isShared;
}
Is there a better way to determine whether the Sender email address in the From field is a shared mailbox email address or not?