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
This commit is contained in:
RKrom 2012-02-03 09:47:43 +00:00
commit cdf5fb52e8

View file

@ -133,43 +133,6 @@ namespace Greenshot.Helpers.OfficeInterop {
}
/// <summary>
/// Export to currently opened Email
/// </summary>
/// <param name="activeInspector"></param>
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;
}
/// <summary>
/// Export the image stored in tmpFile to the Inspector with the caption
@ -187,9 +150,17 @@ namespace Greenshot.Helpers.OfficeInterop {
for(int i=1; i <= inspectors.Count; i++) {
Inspector inspector = outlookApplication.Inspectors[i];
if (inspector.Caption.StartsWith(inspectorCaption)) {
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) {
}
}
}
}
}
}