コード例 #1
0
        internal void SendExceptionEmail(string subject, string userName, string exceptionInfo)
        {
            if (!OfficeAppShortcuts.CheckOutlookExists())
            {
                MessageBox.Show("Error. Unable to detect Outlook, please install Outlook before attempting to send a bug report.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Outlook.Application outlook = new Outlook.Application();

            if (dialogIsAlreadyRunning == true)
            {
                MessageBox.Show("An Outlook window is already open to send a bug report.\n\nPlease send or close the current Outlook window " +
                                "in order to send this report.", "Unable to send bug report", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;
            }

            dialogIsAlreadyRunning = true;

            DialogResult dialogresult = MessageBox.Show($"An error has occurred. Do you wish to send a bug report?", "An error has occurred!",
                                                        MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2);

            if (dialogresult == DialogResult.Yes)
            {
                Outlook._MailItem MailItem = (Outlook._MailItem)outlook.CreateItem(Outlook.OlItemType.olMailItem);

                MailItem.To       = "*****@*****.**";
                MailItem.Subject  = subject;
                MailItem.HTMLBody = $"<html><body> The user <strong>{userName}</strong> has reported the following exception error: <br><br> {exceptionInfo} </body></html>";
                try
                {
                    MailItem.Display(true);
                } catch
                {
                    // add error here for if dialog box is already open.
                    Marshal.ReleaseComObject(outlook);
                    Marshal.ReleaseComObject(MailItem);
                    dialogIsAlreadyRunning = false;
                }

                Marshal.ReleaseComObject(outlook);
                Marshal.ReleaseComObject(MailItem);
            }

            dialogIsAlreadyRunning = false;

            Technical_Support_Control_Panel.Call_Recordings_Form ResetSettings = new Technical_Support_Control_Panel.Call_Recordings_Form();

            ResetSettings.ResetComboBoxSettings();
        }
 private void Office_Shortcuts(object sender, EventArgs e)
 {
     OfficeAppShortcuts.GetShortcuts();
 }