예제 #1
0
        /// <summary>
        /// Get and return the selected item. If it isn't a mail item return null
        /// </summary>
        /// <returns></returns>
        private Outlook.MailItem GetSelectedItem()
        {
            var    olapp     = new Microsoft.Office.Interop.Outlook.Application();
            Object selObject = olapp.ActiveExplorer().Selection[1];

            if (selObject is Microsoft.Office.Interop.Outlook.MailItem)
            {
                return(selObject as Outlook.MailItem);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        /// <summary>
        /// Forward the selected mail
        /// </summary>
        private void ForwardMail()
        {
            if (!String.IsNullOrEmpty(email))
            {
                var    olapp     = new Microsoft.Office.Interop.Outlook.Application();
                Object selObject = olapp.ActiveExplorer().Selection[1];

                if (selObject is Microsoft.Office.Interop.Outlook.MailItem)
                {
                    Outlook.MailItem mailItem = this.GetSelectedItem();
                    if (mailItem != null)
                    {
                        mailItem.Recipients.Add(this.email);
                        mailItem.Send();
                    }
                }
            }
            else
            {
                MessageBox.Show("Email isn't configured");
            }
        }