Exemple #1
0
        private string GetImportanceString(OlImportance importance, bool noParenthesis = false)
        {
            string impString = importance.ToString().Substring(12);

            return(importance == OlImportance.olImportanceNormal ? string.Empty
                : noParenthesis?impString : "(" + impString + ")");
        }
        public static int MapPriority1To2(OlImportance value)
        {
            switch (value)
            {
            case OlImportance.olImportanceLow:
                return(9);

            case OlImportance.olImportanceNormal:
                return(5);

            case OlImportance.olImportanceHigh:
                return(1);
            }

            throw new NotImplementedException(string.Format("Mapping for value '{0}' not implemented.", value));
        }
        private static int?getPriorityID(OlImportance importance)
        {
            if (importance == OlImportance.olImportanceLow)
            {
                return(0);
            }
            else if (importance == OlImportance.olImportanceNormal)
            {
                return(1);
            }
            else if (importance == OlImportance.olImportanceHigh)
            {
                return(2);
            }

            return(null);
        }
Exemple #4
0
        private int MessgageImportanceToInt(OlImportance importance)
        {
            // https://docs.microsoft.com/de-de/office/vba/api/outlook.olresponsestatus
            switch (importance)
            {
            case OlImportance.olImportanceHigh:
                return(2);

            case OlImportance.olImportanceLow:
                return(0);

            case OlImportance.olImportanceNormal:
                return(1);
            }
            DPrint("no recognized OlImportance", 0);
            return(1);
        }
        private static void Send(string buttonId, string subject, OlImportance importance)
        {
            try
            {
                Application outlookApp = new Outlook.Application();
                MailItem newEmail = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);

                // Get the recipients
                string[] recipients = StaticHelper.GetRecipients(buttonId);
                newEmail.To = recipients[0];
                newEmail.CC = recipients[1];
                newEmail.BCC = recipients[2];
                newEmail.Subject = subject;
                newEmail.Importance = importance;
                newEmail.Display(true);
            }
            catch (System.Exception ex)
            {
                StaticHelper.LogMessage(MessageType.Error, ex.ToString());
                throw;
            }
        }
        private static void Send(string buttonId, string subject, OlImportance importance)
        {
            try
            {
                Application outlookApp = new Outlook.Application();
                MailItem    newEmail   = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);

                // Get the recipients
                string[] recipients = StaticHelper.GetRecipients(buttonId);
                newEmail.To         = recipients[0];
                newEmail.CC         = recipients[1];
                newEmail.BCC        = recipients[2];
                newEmail.Subject    = subject;
                newEmail.Importance = importance;
                newEmail.Display(true);
            }
            catch (System.Exception ex)
            {
                StaticHelper.LogMessage(MessageType.Error, ex.ToString());
                throw;
            }
        }
        public void Meeting(IRibbonControl control, string subject, OlImportance importance)
        {
            try
            {
                string[] idParts = control.Id.Split(new[] { StaticHelper.SplitSequence }, StringSplitOptions.RemoveEmptyEntries);
                var outlookApp = new Microsoft.Office.Interop.Outlook.Application();
                AppointmentItem newMeeting = (AppointmentItem)outlookApp.CreateItem(OlItemType.olAppointmentItem);
                newMeeting.MeetingStatus = OlMeetingStatus.olMeeting;

                // Get the recipients
                string[] recipients = StaticHelper.GetRecipients(idParts[0], control.Id);
                if (!string.IsNullOrEmpty(recipients[0]))
                {
                    foreach (Recipient recipRequired in recipients[0].Split(new[] { ';' }).Select(s => newMeeting.Recipients.Add(s)))
                    {
                        recipRequired.Type = (int)OlMeetingRecipientType.olRequired;
                    }
                }

                if (!string.IsNullOrEmpty(recipients[1]))
                {
                    foreach (Recipient recipOptional in recipients[1].Split(new[] { ';' }).Select(s => newMeeting.Recipients.Add(s)))
                    {
                        recipOptional.Type = (int)OlMeetingRecipientType.olOptional;
                    }
                }

                newMeeting.Subject = subject;
                newMeeting.Importance = importance;

                string from = StaticHelper.GetApplicationSetting("MasterEmailAccount");
                if (string.IsNullOrEmpty(from))
                {
                    from = StaticHelper.GetFromAccount(idParts[0]);
                }
 
                if (!string.IsNullOrEmpty(from))
                {
                    // Retrieve the account that has the specific SMTP address.
                    Account account = GetAccountForEmailAddress(outlookApp, from);
                    if (account != null)
                    {
                        // Use this account to send the e-mail.
                        newMeeting.SendUsingAccount = account;
                    }
                }

                if (control.Context is Inspector)
                {
                    Inspector inspector = (Inspector)control.Context;
                    if (inspector.CurrentItem is AppointmentItem)
                    {
                        AppointmentItem m = inspector.CurrentItem as AppointmentItem;

                        // Get the recipients
                        string[] recipients2 = StaticHelper.GetRecipients(idParts[0], control.Id);
                        if (!string.IsNullOrEmpty(recipients2[0]))
                        {
                            foreach (Recipient recipRequired in recipients2[0].Split(new[] { ';' }).Select(s => newMeeting.Recipients.Add(s)))
                            {
                                recipRequired.Type = (int)OlMeetingRecipientType.olRequired;
                            }
                        }

                        if (!string.IsNullOrEmpty(recipients2[1]))
                        {
                            foreach (Recipient recipOptional in recipients2[1].Split(new[] { ';' }).Select(s => newMeeting.Recipients.Add(s)))
                            {
                                recipOptional.Type = (int)OlMeetingRecipientType.olOptional;
                            }
                        }

                        if (string.IsNullOrEmpty(m.Subject))
                        {
                            m.Subject = newMeeting.Subject;
                        }
                        else
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            if (!string.IsNullOrEmpty(standardSuffix))
                            {
                                newMeeting.Subject = newMeeting.Subject.Replace(standardSuffix, string.Empty);
                            }

                            m.Subject = newMeeting.Subject + m.Subject;
                        }

                        if (!string.IsNullOrEmpty(from))
                        {
                            // Retrieve the account that has the specific SMTP address.
                            Account account = GetAccountForEmailAddress(outlookApp, from);
                            if (account != null)
                            {
                                // Use this account to send the e-mail.
                                m.SendUsingAccount = account;
                            }
                        }
                    }
                }
                else
                {
                    newMeeting.Display();
                }
            }
            catch (System.Exception ex)
            {
                StaticHelper.LogMessage(MessageType.Error, ex.ToString());
                throw;
            }
        }
        public void Send(IRibbonControl control, string subject, OlImportance importance)
        {
            try
            {
                string[] idParts = control.Id.Split(new[] { StaticHelper.SplitSequence }, StringSplitOptions.RemoveEmptyEntries);

                var outlookApp = new Microsoft.Office.Interop.Outlook.Application();
                MailItem newEmail = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);

                // Get the recipients
                string[] recipients = StaticHelper.GetRecipients(idParts[0], control.Id);
                newEmail.To = recipients[0];
                newEmail.CC = recipients[1];
                newEmail.BCC = recipients[2];
                newEmail.Subject = subject;
                newEmail.Importance = importance;

                string from = StaticHelper.GetApplicationSetting("MasterEmailAccount");
                if (string.IsNullOrEmpty(from))
                {
                    from = StaticHelper.GetFromAccount(idParts[0]);
                }

                if (!string.IsNullOrEmpty(from))
                {
                    // Retrieve the account that has the specific SMTP address.
                    Account account = GetAccountForEmailAddress(outlookApp, from);
                    if (account != null)
                    {
                        // Use this account to send the e-mail.
                        newEmail.SendUsingAccount = account;
                    }
                }

                if (control.Context is Inspector)
                {
                    Inspector inspector = (Inspector)control.Context;

                    // This handles sharepoint posts
                    if (inspector.CurrentItem is Microsoft.Office.Interop.Outlook.PostItem)
                    {
                        PostItem m = inspector.CurrentItem as PostItem;

                        if (string.IsNullOrEmpty(m.Subject))
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            if (!string.IsNullOrEmpty(standardSuffix))
                            {
                                m.Subject = newEmail.Subject.Replace(standardSuffix, string.Empty);
                            }
                            else
                            {
                                m.Subject = newEmail.Subject;
                            }
                        }
                        else
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            if (!string.IsNullOrEmpty(standardSuffix))
                            {
                                newEmail.Subject = newEmail.Subject.Replace(standardSuffix, string.Empty);
                            }

                            m.Subject = newEmail.Subject + m.Subject;
                        }

                        return;
                    }

                    if (inspector.CurrentItem is MailItem)
                    {
                        MailItem m = inspector.CurrentItem as MailItem;
                        m.Importance = newEmail.Importance;

                        if (!string.IsNullOrEmpty(from))
                        {
                            // Retrieve the account that has the specific SMTP address.
                            Account account = GetAccountForEmailAddress(outlookApp, from);
                            if (account != null)
                            {
                                // Use this account to send the e-mail.
                                m.SendUsingAccount = account;
                            }
                        }

                        if (string.IsNullOrEmpty(m.Subject))
                        {
                            m.Subject = newEmail.Subject;
                        }
                        else
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            if (!string.IsNullOrEmpty(standardSuffix))
                            {
                                newEmail.Subject = newEmail.Subject.Replace(standardSuffix, string.Empty);
                            }

                            m.Subject = newEmail.Subject + m.Subject;
                        }
                    }
                }
                else
                {
                    string html = StaticHelper.GetTemplate(control.Id);
                    if (!string.IsNullOrEmpty(html))
                    {
                        ////newEmail.HTMLBody += html;

                        ////MailItem newEmail2 = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);

                        ////Inspector objSigDoc = newEmail2.GetInspector;

                        ////string s = objSigDoc.ToString();
                    }

                    newEmail.Display();
                }
            }
            catch (System.Exception ex)
            {
                StaticHelper.LogMessage(MessageType.Error, ex.ToString());
                throw;
            }
        }
Exemple #9
0
 private string GetImportanceString(OlImportance importance, bool noParenthesis  = false)
 {
     string impString = importance.ToString().Substring(12);
     return  importance == OlImportance.olImportanceNormal ? string.Empty
         : noParenthesis ? impString : "(" + impString + ")";
 }
Exemple #10
0
        public bool SendEmail(OlItemType olMailItem, string to, string cc, string sub, string documentText, OlImportance olImportanceNormal)
        {
            if (_application == null)
            {
                GetApplicationObject();
            }

            try
            {
                MailItem mailItem = _application.CreateItem(olMailItem);
                mailItem.To         = to;
                mailItem.CC         = cc;
                mailItem.Subject    = sub;
                mailItem.HTMLBody   = documentText;
                mailItem.Importance = olImportanceNormal;
                mailItem.Send();
            }
            catch (System.Exception e)
            {
                throw e;
            }

            return(true);
        }
        public void Meeting(IRibbonControl control, string subject, OlImportance importance)
        {
            try
            {
                string[]        idParts    = control.Id.Split(new[] { StaticHelper.SplitSequence }, StringSplitOptions.RemoveEmptyEntries);
                Application     outlookApp = new ApplicationClass();
                AppointmentItem newMeeting = (AppointmentItem)outlookApp.CreateItem(OlItemType.olAppointmentItem);
                newMeeting.MeetingStatus = OlMeetingStatus.olMeeting;

                // Get the recipients
                string[] recipients = StaticHelper.GetRecipients(idParts[0], control.Id);
                if (!string.IsNullOrEmpty(recipients[0]))
                {
                    foreach (Recipient recipRequired in recipients[0].Split(new[] { ';' }).Select(s => newMeeting.Recipients.Add(s)))
                    {
                        recipRequired.Type = (int)OlMeetingRecipientType.olRequired;
                    }
                }

                if (!string.IsNullOrEmpty(recipients[1]))
                {
                    foreach (Recipient recipOptional in recipients[1].Split(new[] { ';' }).Select(s => newMeeting.Recipients.Add(s)))
                    {
                        recipOptional.Type = (int)OlMeetingRecipientType.olOptional;
                    }
                }

                newMeeting.Subject    = subject;
                newMeeting.Importance = importance;

                string from = StaticHelper.GetApplicationSetting("MasterEmailAccount");
                if (string.IsNullOrEmpty(from))
                {
                    from = StaticHelper.GetFromAccount(idParts[0]);
                }

                if (!string.IsNullOrEmpty(from))
                {
                    // Retrieve the account that has the specific SMTP address.
                    Account account = GetAccountForEmailAddress(outlookApp, from);
                    if (account != null)
                    {
                        // Use this account to send the e-mail.
                        newMeeting.SendUsingAccount = account;
                    }
                }

                if (control.Context is Inspector)
                {
                    Inspector inspector = (Inspector)control.Context;
                    if (inspector.CurrentItem is AppointmentItem)
                    {
                        AppointmentItem m = inspector.CurrentItem as AppointmentItem;

                        // Get the recipients
                        string[] recipients2 = StaticHelper.GetRecipients(idParts[0], control.Id);
                        if (!string.IsNullOrEmpty(recipients2[0]))
                        {
                            foreach (Recipient recipRequired in recipients2[0].Split(new[] { ';' }).Select(s => newMeeting.Recipients.Add(s)))
                            {
                                recipRequired.Type = (int)OlMeetingRecipientType.olRequired;
                            }
                        }

                        if (!string.IsNullOrEmpty(recipients2[1]))
                        {
                            foreach (Recipient recipOptional in recipients2[1].Split(new[] { ';' }).Select(s => newMeeting.Recipients.Add(s)))
                            {
                                recipOptional.Type = (int)OlMeetingRecipientType.olOptional;
                            }
                        }

                        if (string.IsNullOrEmpty(m.Subject))
                        {
                            m.Subject = newMeeting.Subject;
                        }
                        else
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            if (!string.IsNullOrEmpty(standardSuffix))
                            {
                                newMeeting.Subject = newMeeting.Subject.Replace(standardSuffix, string.Empty);
                            }

                            m.Subject = newMeeting.Subject + m.Subject;
                        }

                        if (!string.IsNullOrEmpty(from))
                        {
                            // Retrieve the account that has the specific SMTP address.
                            Account account = GetAccountForEmailAddress(outlookApp, from);
                            if (account != null)
                            {
                                // Use this account to send the e-mail.
                                m.SendUsingAccount = account;
                            }
                        }
                    }
                }
                else
                {
                    newMeeting.Display();
                }
            }
            catch (System.Exception ex)
            {
                StaticHelper.LogMessage(MessageType.Error, ex.ToString());
                throw;
            }
        }
        public void Send(IRibbonControl control, string subject, OlImportance importance)
        {
            try
            {
                string[]    idParts    = control.Id.Split(new[] { StaticHelper.SplitSequence }, StringSplitOptions.RemoveEmptyEntries);
                Application outlookApp = new ApplicationClass();
                MailItem    newEmail   = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);

                // Get the recipients
                string[] recipients = StaticHelper.GetRecipients(idParts[0], control.Id);
                newEmail.To         = recipients[0];
                newEmail.CC         = recipients[1];
                newEmail.BCC        = recipients[2];
                newEmail.Subject    = subject;
                newEmail.Importance = importance;

                string from = StaticHelper.GetApplicationSetting("MasterEmailAccount");
                if (string.IsNullOrEmpty(from))
                {
                    from = StaticHelper.GetFromAccount(idParts[0]);
                }

                if (!string.IsNullOrEmpty(from))
                {
                    // Retrieve the account that has the specific SMTP address.
                    Account account = GetAccountForEmailAddress(outlookApp, from);
                    if (account != null)
                    {
                        // Use this account to send the e-mail.
                        newEmail.SendUsingAccount = account;
                    }
                }

                if (control.Context is Inspector)
                {
                    Inspector inspector = (Inspector)control.Context;

                    // This handles sharepoint posts
                    if (inspector.CurrentItem is Microsoft.Office.Interop.Outlook.PostItem)
                    {
                        PostItem m = inspector.CurrentItem as PostItem;

                        if (string.IsNullOrEmpty(m.Subject))
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            if (!string.IsNullOrEmpty(standardSuffix))
                            {
                                m.Subject = newEmail.Subject.Replace(standardSuffix, string.Empty);
                            }
                            else
                            {
                                m.Subject = newEmail.Subject;
                            }
                        }
                        else
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            if (!string.IsNullOrEmpty(standardSuffix))
                            {
                                newEmail.Subject = newEmail.Subject.Replace(standardSuffix, string.Empty);
                            }

                            m.Subject = newEmail.Subject + m.Subject;
                        }

                        return;
                    }

                    if (inspector.CurrentItem is MailItem)
                    {
                        MailItem m = inspector.CurrentItem as MailItem;
                        if (!string.IsNullOrEmpty(newEmail.To))
                        {
                            m.To = newEmail.To;
                        }

                        if (!string.IsNullOrEmpty(newEmail.CC))
                        {
                            m.CC = newEmail.CC;
                        }

                        if (!string.IsNullOrEmpty(newEmail.BCC))
                        {
                            m.BCC = newEmail.BCC;
                        }

                        m.Importance = newEmail.Importance;

                        if (!string.IsNullOrEmpty(from))
                        {
                            // Retrieve the account that has the specific SMTP address.
                            Account account = GetAccountForEmailAddress(outlookApp, from);
                            if (account != null)
                            {
                                // Use this account to send the e-mail.
                                m.SendUsingAccount = account;
                            }
                        }

                        if (string.IsNullOrEmpty(m.Subject))
                        {
                            m.Subject = newEmail.Subject;
                        }
                        else
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            if (!string.IsNullOrEmpty(standardSuffix))
                            {
                                newEmail.Subject = newEmail.Subject.Replace(standardSuffix, string.Empty);
                            }

                            m.Subject = newEmail.Subject + m.Subject;
                        }
                    }
                }
                else
                {
                    string html = StaticHelper.GetTemplate(control.Id);
                    if (!string.IsNullOrEmpty(html))
                    {
                        ////newEmail.HTMLBody += html;

                        ////MailItem newEmail2 = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);

                        ////Inspector objSigDoc = newEmail2.GetInspector;

                        ////string s = objSigDoc.ToString();
                    }

                    newEmail.Display();
                }
            }
            catch (System.Exception ex)
            {
                StaticHelper.LogMessage(MessageType.Error, ex.ToString());
                throw;
            }
        }
        public void Send(IRibbonControl control, string subject, OlImportance importance)
        {
            try
            {
                string[] idParts = control.Id.Split(new[] { StaticHelper.SplitSequence }, StringSplitOptions.RemoveEmptyEntries);

                var      outlookApp = new Microsoft.Office.Interop.Outlook.Application();
                MailItem newEmail   = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);

                // Get the recipients
                string[] recipients = StaticHelper.GetRecipients(idParts[0], control.Id);
                newEmail.To         = recipients[0];
                newEmail.CC         = recipients[1];
                newEmail.BCC        = recipients[2];
                newEmail.Subject    = subject;
                newEmail.Importance = importance;

                string from = StaticHelper.GetApplicationSetting("MasterEmailAccount");
                if (string.IsNullOrEmpty(from))
                {
                    from = StaticHelper.GetFromAccount(idParts[0]);
                }

                if (!string.IsNullOrEmpty(from))
                {
                    // Retrieve the account that has the specific SMTP address.
                    Account account = GetAccountForEmailAddress(outlookApp, from);
                    if (account != null)
                    {
                        // Use this account to send the e-mail.
                        newEmail.SendUsingAccount = account;
                    }
                }
                else
                {
                    // See if we can determine which email account to send from based on the current folder. User may have multiple mail accounts.
                    try
                    {
                        Microsoft.Office.Interop.Outlook.AddressEntry addrEntry = null;

                        // Get the Store for CurrentFolder.
                        Microsoft.Office.Interop.Outlook.Folder folder = outlookApp.ActiveExplorer().CurrentFolder as Microsoft.Office.Interop.Outlook.Folder;
                        if (folder != null)
                        {
                            Microsoft.Office.Interop.Outlook.Store    store    = folder.Store;
                            Microsoft.Office.Interop.Outlook.Accounts accounts = outlookApp.Session.Accounts;

                            // Enumerate accounts to find account.DeliveryStore for store.
                            foreach (Microsoft.Office.Interop.Outlook.Account account in accounts)
                            {
                                if (account.DeliveryStore.StoreID == store.StoreID)
                                {
                                    addrEntry = account.CurrentUser.AddressEntry;
                                    break;
                                }
                            }

                            newEmail.Sender = addrEntry;
                        }
                    }
                    catch
                    {
                        // Intentionally swallow for now
                    }
                }

                var context = control.Context as Inspector;
                if (context != null)
                {
                    Inspector inspector = context;

                    // This handles sharepoint posts
                    if (inspector.CurrentItem is Microsoft.Office.Interop.Outlook.PostItem)
                    {
                        PostItem m = inspector.CurrentItem as PostItem;

                        if (string.IsNullOrEmpty(m.Subject))
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            m.Subject = !string.IsNullOrEmpty(standardSuffix) ? newEmail.Subject.Replace(standardSuffix, string.Empty) : newEmail.Subject;
                        }
                        else
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            if (!string.IsNullOrEmpty(standardSuffix))
                            {
                                newEmail.Subject = newEmail.Subject.Replace(standardSuffix, string.Empty);
                            }

                            m.Subject = newEmail.Subject + m.Subject;
                        }

                        return;
                    }

                    if (inspector.CurrentItem is MailItem)
                    {
                        MailItem m = inspector.CurrentItem as MailItem;
                        m.Importance = newEmail.Importance;

                        if (!string.IsNullOrEmpty(from))
                        {
                            // Retrieve the account that has the specific SMTP address.
                            Account account = GetAccountForEmailAddress(outlookApp, from);
                            if (account != null)
                            {
                                // Use this account to send the e-mail.
                                m.SendUsingAccount = account;
                            }
                        }

                        if (string.IsNullOrEmpty(m.Subject))
                        {
                            m.Subject = newEmail.Subject;
                        }
                        else
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            if (!string.IsNullOrEmpty(standardSuffix))
                            {
                                newEmail.Subject = newEmail.Subject.Replace(standardSuffix, string.Empty);
                            }

                            m.Subject = newEmail.Subject + m.Subject;
                        }
                    }
                }
                else
                {
                    string html = StaticHelper.GetTemplate(control.Id);
                    if (!string.IsNullOrEmpty(html))
                    {
                        ////newEmail.HTMLBody += html;

                        ////MailItem newEmail2 = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);

                        ////Inspector objSigDoc = newEmail2.GetInspector;

                        ////string s = objSigDoc.ToString();
                    }

                    newEmail.Display();
                }
            }
            catch (System.Exception ex)
            {
                StaticHelper.LogMessage(MessageType.Error, ex.ToString());
                throw;
            }
        }
    public static int MapPriority1To2 (OlImportance value)
    {
      switch (value)
      {
        case OlImportance.olImportanceLow:
          return 9;
        case OlImportance.olImportanceNormal:
          return 5;
        case OlImportance.olImportanceHigh:
          return 1;
      }

      throw new NotImplementedException (string.Format ("Mapping for value '{0}' not implemented.", value));
    }
        public void Send(IRibbonControl control, string subject, OlImportance importance)
        {
            try
            {
                string[] idParts = control.Id.Split(new[] { StaticHelper.SplitSequence }, StringSplitOptions.RemoveEmptyEntries);

                var outlookApp = new Microsoft.Office.Interop.Outlook.Application();
                MailItem newEmail = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);

                // Get the recipients
                string[] recipients = StaticHelper.GetRecipients(idParts[0], control.Id);
                newEmail.To = recipients[0];
                newEmail.CC = recipients[1];
                newEmail.BCC = recipients[2];
                newEmail.Subject = subject;
                newEmail.Importance = importance;

                string from = StaticHelper.GetApplicationSetting("MasterEmailAccount");
                if (string.IsNullOrEmpty(from))
                {
                    from = StaticHelper.GetFromAccount(idParts[0]);
                }

                if (!string.IsNullOrEmpty(from))
                {
                    // Retrieve the account that has the specific SMTP address.
                    Account account = GetAccountForEmailAddress(outlookApp, from);
                    if (account != null)
                    {
                        // Use this account to send the e-mail.
                        newEmail.SendUsingAccount = account;
                    }
                }
                else
                {
                    // See if we can determine which email account to send from based on the current folder. User may have multiple mail accounts.
                    try
                    {
                        Microsoft.Office.Interop.Outlook.AddressEntry addrEntry = null;

                        // Get the Store for CurrentFolder.
                        Microsoft.Office.Interop.Outlook.Folder folder = outlookApp.ActiveExplorer().CurrentFolder as Microsoft.Office.Interop.Outlook.Folder;
                        if (folder != null)
                        {
                            Microsoft.Office.Interop.Outlook.Store store = folder.Store;
                            Microsoft.Office.Interop.Outlook.Accounts accounts = outlookApp.Session.Accounts;

                            // Enumerate accounts to find account.DeliveryStore for store.
                            foreach (Microsoft.Office.Interop.Outlook.Account account in accounts)
                            {
                                if (account.DeliveryStore.StoreID == store.StoreID)
                                {
                                    addrEntry = account.CurrentUser.AddressEntry;
                                    break;
                                }
                            }

                            newEmail.Sender = addrEntry;
                        }
                    }
                    catch 
                    {
                     // Intentionally swallow for now
                    }
                }

                var context = control.Context as Inspector;
                if (context != null)
                {
                    Inspector inspector = context;

                    // This handles sharepoint posts
                    if (inspector.CurrentItem is Microsoft.Office.Interop.Outlook.PostItem)
                    {
                        PostItem m = inspector.CurrentItem as PostItem;

                        if (string.IsNullOrEmpty(m.Subject))
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            m.Subject = !string.IsNullOrEmpty(standardSuffix) ? newEmail.Subject.Replace(standardSuffix, string.Empty) : newEmail.Subject;
                        }
                        else
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            if (!string.IsNullOrEmpty(standardSuffix))
                            {
                                newEmail.Subject = newEmail.Subject.Replace(standardSuffix, string.Empty);
                            }

                            m.Subject = newEmail.Subject + m.Subject;
                        }

                        return;
                    }

                    if (inspector.CurrentItem is MailItem)
                    {
                        MailItem m = inspector.CurrentItem as MailItem;
                        m.Importance = newEmail.Importance;

                        if (!string.IsNullOrEmpty(from))
                        {
                            // Retrieve the account that has the specific SMTP address.
                            Account account = GetAccountForEmailAddress(outlookApp, from);
                            if (account != null)
                            {
                                // Use this account to send the e-mail.
                                m.SendUsingAccount = account;
                            }
                        }

                        if (string.IsNullOrEmpty(m.Subject))
                        {
                            m.Subject = newEmail.Subject;
                        }
                        else
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            if (!string.IsNullOrEmpty(standardSuffix))
                            {
                                newEmail.Subject = newEmail.Subject.Replace(standardSuffix, string.Empty);
                            }

                            m.Subject = newEmail.Subject + m.Subject;
                        }
                    }
                }
                else
                {
                    string html = StaticHelper.GetTemplate(control.Id);
                    if (!string.IsNullOrEmpty(html))
                    {
                        ////newEmail.HTMLBody += html;

                        ////MailItem newEmail2 = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);

                        ////Inspector objSigDoc = newEmail2.GetInspector;

                        ////string s = objSigDoc.ToString();
                    }

                    newEmail.Display();
                }
            }
            catch (System.Exception ex)
            {
                StaticHelper.LogMessage(MessageType.Error, ex.ToString());
                throw;
            }
        }