From cdf5fb52e8e97ade178564012efb1e4c5a34ff25 Mon Sep 17 00:00:00 2001 From: RKrom Date: Fri, 3 Feb 2012 09:47:43 +0000 Subject: [PATCH] Fixed problem in Outlook Export when 2 Emails are open with the same name, one is the answer to a received email. The received email was taken as a Target, which is easily fixed by adding a check on "Sent" (as is done when retrieving the list of possible targets). git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1627 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- .../Helpers/OfficeInterop/OutlookWrapper.cs | 49 ++++--------------- 1 file changed, 10 insertions(+), 39 deletions(-) diff --git a/Greenshot/Helpers/OfficeInterop/OutlookWrapper.cs b/Greenshot/Helpers/OfficeInterop/OutlookWrapper.cs index 0fa305467..a45fe09df 100644 --- a/Greenshot/Helpers/OfficeInterop/OutlookWrapper.cs +++ b/Greenshot/Helpers/OfficeInterop/OutlookWrapper.cs @@ -133,44 +133,7 @@ namespace Greenshot.Helpers.OfficeInterop { } - /// - /// Export to currently opened Email - /// - /// - private static bool ExportToOpenEmail(IOutlookApplication outlookApplication, string tmpFile, string subject) { - using (Inspector activeInspector = outlookApplication.ActiveInspector()) { - if (activeInspector != null) { - try { - LOG.DebugFormat("Checking active inspector '{0}'", activeInspector.Caption); - if (ExportToInspector(activeInspector, tmpFile, subject)) { - return true; - } - } catch (Exception ex) { - LOG.DebugFormat("Problem exporting to activeinspector: {0}", ex.Message); - } - } - } - Inspectors inspectors = outlookApplication.Inspectors; - if (inspectors != null && inspectors.Count > 0) { - LOG.DebugFormat("Got {0} inspectors to check", inspectors.Count); - for(int i=1; i <= inspectors.Count; i++) { - Inspector inspector = outlookApplication.Inspectors[i]; - LOG.DebugFormat("Checking inspector '{0}'", inspector.Caption); - try { - bool exported = ExportToInspector(inspector, tmpFile, subject); - if (exported) { - return true; - } - } catch (Exception ex) { - LOG.DebugFormat("Problem exporting to inspector: {0}", ex.Message); - } - - } - } - - return false; - } - + /// /// Export the image stored in tmpFile to the Inspector with the caption /// @@ -187,7 +150,15 @@ namespace Greenshot.Helpers.OfficeInterop { for(int i=1; i <= inspectors.Count; i++) { Inspector inspector = outlookApplication.Inspectors[i]; if (inspector.Caption.StartsWith(inspectorCaption)) { - return ExportToInspector(inspector, tmpFile, attachmentName); + try { + Item currentMail = inspector.CurrentItem; + if (currentMail != null && OlObjectClass.olMail.Equals(currentMail.Class)) { + if (currentMail != null && !currentMail.Sent) { + return ExportToInspector(inspector, tmpFile, attachmentName); + } + } + } catch (Exception) { + } } } }