I am writing an Outlook Add-in that will be used to track number of emails replied to or forwarded. On the development PC, I have outlook 2010 and the code works fine but it's failing in outlook 2007 which is the version installed on end user's PC. Error message, "Cannot perform runtime binding to null reference". All I need before sending the email, is the mailbox sent from, the recipient's email address and the subject. here is my code for sending an email as a new email, can you please advise on what is the difference in the API used between office 2010 and 2007? what should I use instead?
private void Send_Click(object sender, RibbonControlEventArgs e)
{
try
{
string _sub, _from, _to;
var inspector = this.Context as Outlook.Inspector;
dynamic mail = inspector.CurrentItem;
_from = mail.SendUsingAccount.DisplayName.ToString();
_to = mail.To.ToString();
_sub = mail.Subject.ToString();
/*
some extra code to save to database before sending email
*/
mail.Send();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error occured in send command");
}
}