diff --git a/Greenshot/Destinations/EmailDestination.cs b/Greenshot/Destinations/EmailDestination.cs index 3233e11ae..173a31291 100644 --- a/Greenshot/Destinations/EmailDestination.cs +++ b/Greenshot/Destinations/EmailDestination.cs @@ -49,9 +49,8 @@ namespace Greenshot.Destinations { isActiveFlag = true; mapiClient = EmailConfigHelper.GetMapiClient(); if (!string.IsNullOrEmpty(mapiClient)) { - if (mapiClient.ToLower().Contains("microsoft outlook")) { - isActiveFlag = false; - } + // Active as we have a mapi client, can be disabled later + isActiveFlag = true; } } } @@ -84,6 +83,15 @@ namespace Greenshot.Destinations { public override bool isActive { get { + if (isActiveFlag) { + // Disable if the office plugin is installed and the client is outlook + Type outlookdestination = Type.GetType("GreenshotOfficePlugin.OutlookDestination,GreenshotOfficePlugin"); + if (outlookdestination != null) { + if (mapiClient.ToLower().Contains("microsoft outlook")) { + isActiveFlag = false; + } + } + } return base.isActive && isActiveFlag; } } diff --git a/Greenshot/Helpers/MailHelper.cs b/Greenshot/Helpers/MailHelper.cs index f1da599e8..dea02bd4f 100644 --- a/Greenshot/Helpers/MailHelper.cs +++ b/Greenshot/Helpers/MailHelper.cs @@ -55,10 +55,16 @@ namespace Greenshot.Helpers { public static void SendImage(string fullPath, string title) { MapiMailMessage message = new MapiMailMessage(title, null); message.Files.Add(fullPath); - message._recipientCollection.Add(new Recipient(conf.MailApiTo, RecipientType.To)); - message._recipientCollection.Add(new Recipient(conf.MailApiCC, RecipientType.CC)); - message._recipientCollection.Add(new Recipient(conf.MailApiBCC, RecipientType.BCC)); - message.ShowDialog(); + if (!string.IsNullOrEmpty(conf.MailApiTo)) { + message._recipientCollection.Add(new Recipient(conf.MailApiTo, RecipientType.To)); + } + if (!string.IsNullOrEmpty(conf.MailApiCC)) { + message._recipientCollection.Add(new Recipient(conf.MailApiCC, RecipientType.CC)); + } + if (!string.IsNullOrEmpty(conf.MailApiTo)) { + message._recipientCollection.Add(new Recipient(conf.MailApiBCC, RecipientType.BCC)); + } + message.ShowDialog(); } @@ -251,7 +257,9 @@ namespace Greenshot.Helpers { // Check for error if (errorCode != MAPI_CODES.SUCCESS && errorCode != MAPI_CODES.USER_ABORT) { - _LogErrorMapi(errorCode); + string errorText = GetMapiError(errorCode); + LOG.Error("Error sending MAPI Email. Error: " + errorText + " (code = " + errorCode + ")."); + MessageBox.Show(errorText, "Mail (MAPI) destination", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } @@ -350,7 +358,7 @@ namespace Greenshot.Helpers { /// /// Logs any Mapi errors. /// - private void _LogErrorMapi(MAPI_CODES errorCode) { + private string GetMapiError(MAPI_CODES errorCode) { string error = string.Empty; @@ -437,8 +445,7 @@ namespace Greenshot.Helpers { error = "MAPI Invalid parameter."; break; } - - LOG.Error("Error sending MAPI Email. Error: " + error + " (code = " + errorCode + ")."); + return error; } #endregion Private Methods