Changes for Outlook 2013, the editing of an email can now be done inside the "explorer", the old code didn't know this and therefore didn't find a target . These changes have not been testet on 2013 yet, but don't seem to break Outlook 2010.

This commit is contained in:
RKrom 2014-03-17 11:02:02 +01:00
commit 3204b92d53
8 changed files with 372 additions and 153 deletions

View file

@ -44,6 +44,7 @@ namespace Greenshot.Interop.Office {
private const int OUTLOOK_2003 = 11; private const int OUTLOOK_2003 = 11;
private const int OUTLOOK_2007 = 12; private const int OUTLOOK_2007 = 12;
private const int OUTLOOK_2010 = 14; private const int OUTLOOK_2010 = 14;
private const int OUTLOOK_2013 = 15;
// The signature key can be found at: // The signature key can be found at:
// HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\<DefaultProfile>\9375CFF0413111d3B88A00104B2A6676\<xxxx> [New Signature] // HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\<DefaultProfile>\9375CFF0413111d3B88A00104B2A6676\<xxxx> [New Signature]
@ -65,12 +66,26 @@ namespace Greenshot.Interop.Office {
return null; return null;
} }
using (Inspectors inspectors = outlookApplication.Inspectors) { if (outlookVersion.Major >= OUTLOOK_2013) {
// Check inline "panel" for Outlook 2013
using (var activeExplorer = outlookApplication.ActiveExplorer()) {
if (activeExplorer != null) {
using (var inlineResponse = activeExplorer.ActiveInlineResponse) {
if (canExportToInspector(inlineResponse, allowMeetingAsTarget)) {
OlObjectClass currentItemClass = inlineResponse.Class;
inspectorCaptions.Add(activeExplorer.Caption, currentItemClass);
}
}
}
}
}
using (IInspectors inspectors = outlookApplication.Inspectors) {
if (inspectors != null && inspectors.Count > 0) { if (inspectors != null && inspectors.Count > 0) {
for (int i = 1; i <= inspectors.Count; i++) { for (int i = 1; i <= inspectors.Count; i++) {
using (Inspector inspector = outlookApplication.Inspectors[i]) { using (IInspector inspector = outlookApplication.Inspectors[i]) {
string inspectorCaption = inspector.Caption; string inspectorCaption = inspector.Caption;
using (Item currentItem = inspector.CurrentItem) { using (IItem currentItem = inspector.CurrentItem) {
if (canExportToInspector(currentItem, allowMeetingAsTarget)) { if (canExportToInspector(currentItem, allowMeetingAsTarget)) {
OlObjectClass currentItemClass = currentItem.Class; OlObjectClass currentItemClass = currentItem.Class;
inspectorCaptions.Add(inspector.Caption, currentItemClass); inspectorCaptions.Add(inspector.Caption, currentItemClass);
@ -93,7 +108,7 @@ namespace Greenshot.Interop.Office {
/// <param name="currentItem">the Item to check</param> /// <param name="currentItem">the Item to check</param>
/// <param name="allowMeetingAsTarget">bool true if also exporting to meetings</param> /// <param name="allowMeetingAsTarget">bool true if also exporting to meetings</param>
/// <returns></returns> /// <returns></returns>
private static bool canExportToInspector(Item currentItem, bool allowMeetingAsTarget) { private static bool canExportToInspector(IItem currentItem, bool allowMeetingAsTarget) {
try { try {
if (currentItem != null) { if (currentItem != null) {
OlObjectClass currentItemClass = currentItem.Class; OlObjectClass currentItemClass = currentItem.Class;
@ -133,14 +148,37 @@ namespace Greenshot.Interop.Office {
bool allowMeetingAsTarget = true; bool allowMeetingAsTarget = true;
using (IOutlookApplication outlookApplication = GetOrCreateOutlookApplication()) { using (IOutlookApplication outlookApplication = GetOrCreateOutlookApplication()) {
if (outlookApplication != null) { if (outlookApplication != null) {
Inspectors inspectors = outlookApplication.Inspectors;
if (outlookVersion.Major >= OUTLOOK_2013) {
// Check inline "panel" for Outlook 2013
using (var activeExplorer = outlookApplication.ActiveExplorer()) {
if (activeExplorer != null) {
var currentCaption = activeExplorer.Caption;
if (currentCaption.StartsWith(inspectorCaption)) {
using (var inlineResponse = activeExplorer.ActiveInlineResponse) {
using (IItem currentItem = activeExplorer.ActiveInlineResponse) {
if (canExportToInspector(inlineResponse, allowMeetingAsTarget)) {
try {
return ExportToInspector(activeExplorer, currentItem, tmpFile, attachmentName);
} catch (Exception exExport) {
LOG.Error("Export to " + currentCaption + " failed.", exExport);
}
}
}
}
}
}
}
}
IInspectors inspectors = outlookApplication.Inspectors;
if (inspectors != null && inspectors.Count > 0) { if (inspectors != null && inspectors.Count > 0) {
LOG.DebugFormat("Got {0} inspectors to check", inspectors.Count); LOG.DebugFormat("Got {0} inspectors to check", inspectors.Count);
for (int i = 1; i <= inspectors.Count; i++) { for (int i = 1; i <= inspectors.Count; i++) {
using (Inspector inspector = outlookApplication.Inspectors[i]) { using (IInspector inspector = outlookApplication.Inspectors[i]) {
string currentCaption = inspector.Caption; string currentCaption = inspector.Caption;
if (currentCaption.StartsWith(inspectorCaption)) { if (currentCaption.StartsWith(inspectorCaption)) {
using (Item currentItem = inspector.CurrentItem) { using (IItem currentItem = inspector.CurrentItem) {
if (canExportToInspector(currentItem, allowMeetingAsTarget)) { if (canExportToInspector(currentItem, allowMeetingAsTarget)) {
try { try {
return ExportToInspector(inspector, currentItem, tmpFile, attachmentName); return ExportToInspector(inspector, currentItem, tmpFile, attachmentName);
@ -166,7 +204,7 @@ namespace Greenshot.Interop.Office {
/// <param name="tmpFile"></param> /// <param name="tmpFile"></param>
/// <param name="attachmentName"></param> /// <param name="attachmentName"></param>
/// <returns></returns> /// <returns></returns>
private static bool ExportToInspector(Inspector inspector, Item currentItem, string tmpFile, string attachmentName) { private static bool ExportToInspector(ICommonExplorer inspectorOrExplorer, IItem currentItem, string tmpFile, string attachmentName) {
if (currentItem == null) { if (currentItem == null) {
LOG.Warn("No current item."); LOG.Warn("No current item.");
return false; return false;
@ -191,7 +229,7 @@ namespace Greenshot.Interop.Office {
// Make sure the inspector is activated, only this way the word editor is active! // Make sure the inspector is activated, only this way the word editor is active!
// This also ensures that the window is visible! // This also ensures that the window is visible!
inspector.Activate(); inspectorOrExplorer.Activate();
bool isTextFormat = false; bool isTextFormat = false;
if (isMail) { if (isMail) {
isTextFormat = OlBodyFormat.olFormatPlain.Equals(mailItem.BodyFormat); isTextFormat = OlBodyFormat.olFormatPlain.Equals(mailItem.BodyFormat);
@ -200,9 +238,19 @@ namespace Greenshot.Interop.Office {
// Check for wordmail, if so use the wordexporter // Check for wordmail, if so use the wordexporter
// http://msdn.microsoft.com/en-us/library/dd492012%28v=office.12%29.aspx // http://msdn.microsoft.com/en-us/library/dd492012%28v=office.12%29.aspx
// Earlier versions of Outlook also supported an Inspector.HTMLEditor object property, but since Internet Explorer is no longer the rendering engine for HTML messages and posts, HTMLEditor is no longer supported. // Earlier versions of Outlook also supported an Inspector.HTMLEditor object property, but since Internet Explorer is no longer the rendering engine for HTML messages and posts, HTMLEditor is no longer supported.
if (inspector.IsWordMail() && inspector.WordEditor != null) { IWordDocument wordDocument = null;
if (inspectorOrExplorer is IExplorer) {
var explorer = inspectorOrExplorer as IExplorer;
wordDocument = explorer.ActiveInlineResponseWordEditor;
} else if (inspectorOrExplorer is IInspector) {
var inspector = inspectorOrExplorer as IInspector;
if (inspector.IsWordMail()) {
wordDocument = inspector.WordEditor;
}
}
if (wordDocument != null) {
try { try {
if (WordExporter.InsertIntoExistingDocument(inspector.WordEditor.Application, inspector.WordEditor, tmpFile, null, null)) { if (WordExporter.InsertIntoExistingDocument(wordDocument.Application, wordDocument, tmpFile, null, null)) {
LOG.Info("Inserted into Wordmail"); LOG.Info("Inserted into Wordmail");
// check the format afterwards, otherwise we lose the selection // check the format afterwards, otherwise we lose the selection
@ -240,11 +288,11 @@ namespace Greenshot.Interop.Office {
//} //}
bool inlinePossible = false; bool inlinePossible = false;
if (OlBodyFormat.olFormatHTML.Equals(mailItem.BodyFormat)) { if (inspectorOrExplorer is IInspector && OlBodyFormat.olFormatHTML.Equals(mailItem.BodyFormat)) {
// if html we can try to inline it // if html we can try to inline it
// The following might cause a security popup... can't ignore it. // The following might cause a security popup... can't ignore it.
try { try {
IHTMLDocument2 document2 = inspector.HTMLEditor as IHTMLDocument2; IHTMLDocument2 document2 = (inspectorOrExplorer as IInspector).HTMLEditor as IHTMLDocument2;
if (document2 != null) { if (document2 != null) {
IHTMLSelectionObject selection = document2.selection; IHTMLSelectionObject selection = document2.selection;
if (selection != null) { if (selection != null) {
@ -254,13 +302,13 @@ namespace Greenshot.Interop.Office {
range.pasteHTML("<BR/><IMG border=0 hspace=0 alt=\"" + attachmentName + "\" align=baseline src=\"cid:" + contentID + "\"><BR/>"); range.pasteHTML("<BR/><IMG border=0 hspace=0 alt=\"" + attachmentName + "\" align=baseline src=\"cid:" + contentID + "\"><BR/>");
inlinePossible = true; inlinePossible = true;
} else { } else {
LOG.DebugFormat("No range for '{0}'", inspector.Caption); LOG.DebugFormat("No range for '{0}'", inspectorOrExplorer.Caption);
} }
} else { } else {
LOG.DebugFormat("No selection for '{0}'", inspector.Caption); LOG.DebugFormat("No selection for '{0}'", inspectorOrExplorer.Caption);
} }
} else { } else {
LOG.DebugFormat("No HTML editor for '{0}'", inspector.Caption); LOG.DebugFormat("No HTML editor for '{0}'", inspectorOrExplorer.Caption);
} }
} catch (Exception e) { } catch (Exception e) {
// Continue with non inline image // Continue with non inline image
@ -269,24 +317,24 @@ namespace Greenshot.Interop.Office {
} }
// Create the attachment (if inlined the attachment isn't visible as attachment!) // Create the attachment (if inlined the attachment isn't visible as attachment!)
using (Attachment attachment = mailItem.Attachments.Add(tmpFile, OlAttachmentType.olByValue, inlinePossible ? 0 : 1, attachmentName)) { using (IAttachment attachment = mailItem.Attachments.Add(tmpFile, OlAttachmentType.olByValue, inlinePossible ? 0 : 1, attachmentName)) {
if (outlookVersion.Major >= OUTLOOK_2007) { if (outlookVersion.Major >= OUTLOOK_2007) {
// Add the content id to the attachment, this only works for Outlook >= 2007 // Add the content id to the attachment, this only works for Outlook >= 2007
try { try {
PropertyAccessor propertyAccessor = attachment.PropertyAccessor; IPropertyAccessor propertyAccessor = attachment.PropertyAccessor;
propertyAccessor.SetProperty(PropTag.ATTACHMENT_CONTENT_ID, contentID); propertyAccessor.SetProperty(PropTag.ATTACHMENT_CONTENT_ID, contentID);
} catch { } catch {
} }
} }
} }
} catch (Exception ex) { } catch (Exception ex) {
LOG.WarnFormat("Problem while trying to add attachment to Item '{0}' : {1}", inspector.Caption, ex); LOG.WarnFormat("Problem while trying to add attachment to Item '{0}' : {1}", inspectorOrExplorer.Caption, ex);
return false; return false;
} }
try { try {
inspector.Activate(); inspectorOrExplorer.Activate();
} catch (Exception ex) { } catch (Exception ex) {
LOG.Warn("Problem activating inspector: ", ex); LOG.Warn("Problem activating inspector/explorer: ", ex);
return false; return false;
} }
LOG.Debug("Finished!"); LOG.Debug("Finished!");
@ -299,7 +347,7 @@ namespace Greenshot.Interop.Office {
/// <param name="tmpFile"></param> /// <param name="tmpFile"></param>
/// <param name="captureDetails"></param> /// <param name="captureDetails"></param>
private static void ExportToNewEmail(IOutlookApplication outlookApplication, EmailFormat format, string tmpFile, string subject, string attachmentName, string to, string CC, string BCC, string url) { private static void ExportToNewEmail(IOutlookApplication outlookApplication, EmailFormat format, string tmpFile, string subject, string attachmentName, string to, string CC, string BCC, string url) {
Item newItem = outlookApplication.CreateItem(OlItemType.olMailItem); IItem newItem = outlookApplication.CreateItem(OlItemType.olMailItem);
if (newItem == null) { if (newItem == null) {
return; return;
} }
@ -336,12 +384,12 @@ namespace Greenshot.Interop.Office {
default: default:
string contentID = Path.GetFileName(tmpFile); string contentID = Path.GetFileName(tmpFile);
// Create the attachment // Create the attachment
using (Attachment attachment = newMail.Attachments.Add(tmpFile, OlAttachmentType.olByValue, 0, attachmentName)) { using (IAttachment attachment = newMail.Attachments.Add(tmpFile, OlAttachmentType.olByValue, 0, attachmentName)) {
// add content ID to the attachment // add content ID to the attachment
if (outlookVersion.Major >= OUTLOOK_2007) { if (outlookVersion.Major >= OUTLOOK_2007) {
try { try {
contentID = Guid.NewGuid().ToString(); contentID = Guid.NewGuid().ToString();
PropertyAccessor propertyAccessor = attachment.PropertyAccessor; IPropertyAccessor propertyAccessor = attachment.PropertyAccessor;
propertyAccessor.SetProperty(PropTag.ATTACHMENT_CONTENT_ID, contentID); propertyAccessor.SetProperty(PropTag.ATTACHMENT_CONTENT_ID, contentID);
} catch { } catch {
LOG.Info("Error working with the PropertyAccessor, using filename as contentid"); LOG.Info("Error working with the PropertyAccessor, using filename as contentid");

View file

@ -22,7 +22,7 @@
namespace Greenshot.Interop.Office { namespace Greenshot.Interop.Office {
// See http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.application.aspx // See http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.application.aspx
[ComProgId("Excel.Application")] [ComProgId("Excel.Application")]
public interface IExcelApplication : Common { public interface IExcelApplication : ICommon {
IWorkbook ActiveWorkbook { get; } IWorkbook ActiveWorkbook { get; }
//ISelection Selection {get;} //ISelection Selection {get;}
IWorkbooks Workbooks { get; } IWorkbooks Workbooks { get; }
@ -30,14 +30,14 @@ namespace Greenshot.Interop.Office {
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.aspx
public interface IWorkbooks : Common, Collection { public interface IWorkbooks : ICommon, ICollection {
IWorkbook Add(object template); IWorkbook Add(object template);
// Use index + 1!! // Use index + 1!!
IWorkbook this[object Index] { get; } IWorkbook this[object Index] { get; }
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbook.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbook.aspx
public interface IWorkbook : Common { public interface IWorkbook : ICommon {
IWorksheet ActiveSheet { get; } IWorksheet ActiveSheet { get; }
string Name { get; } string Name { get; }
void Activate(); void Activate();
@ -45,19 +45,19 @@ namespace Greenshot.Interop.Office {
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel._worksheet_members.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel._worksheet_members.aspx
public interface IWorksheet : Common { public interface IWorksheet : ICommon {
IPictures Pictures { get; } IPictures Pictures { get; }
IShapes Shapes {get; } IShapes Shapes {get; }
string Name { get; } string Name { get; }
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.iworksheets_members.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.iworksheets_members.aspx
public interface IWorksheets : Common, Collection { public interface IWorksheets : ICommon, ICollection {
// Use index + 1!! // Use index + 1!!
IWorksheet this[object Index] { get; } IWorksheet this[object Index] { get; }
} }
public interface IPictures : Common, Collection { public interface IPictures : ICommon, ICollection {
// Use index + 1!! // Use index + 1!!
//IPicture this[object Index] { get; } //IPicture this[object Index] { get; }
void Insert(string file); void Insert(string file);

View file

@ -24,7 +24,7 @@ namespace Greenshot.Interop.Office {
/// <summary> /// <summary>
/// If the "type" this[object index] { get; } is implemented, use index + 1!!! (starts at 1) /// If the "type" this[object index] { get; } is implemented, use index + 1!!! (starts at 1)
/// </summary> /// </summary>
public interface Collection : Common, IEnumerable { public interface ICollection : ICommon, IEnumerable {
int Count { get; } int Count { get; }
void Remove(int index); void Remove(int index);
} }

View file

@ -25,7 +25,7 @@ namespace Greenshot.Interop.Office {
// See http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.applicationclass_members%28v=Office.11%29.aspx // See http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.applicationclass_members%28v=Office.11%29.aspx
[ComProgId("OneNote.Application")] [ComProgId("OneNote.Application")]
public interface IOneNoteApplication : Common { public interface IOneNoteApplication : ICommon {
/// <summary> /// <summary>
/// Make sure that the notebookXml is of type string, e.g. "", otherwise a type error occurs. /// Make sure that the notebookXml is of type string, e.g. "", otherwise a type error occurs.
/// For more info on the methods: http://msdn.microsoft.com/en-us/library/gg649853.aspx /// For more info on the methods: http://msdn.microsoft.com/en-us/library/gg649853.aspx

View file

@ -21,27 +21,52 @@
using System; using System;
using System.Collections; using System.Collections;
/// <summary>
/// This utils class should help setting the content-id on the attachment for Outlook < 2007
/// But this somehow doesn't work yet
/// </summary>
namespace Greenshot.Interop.Office { namespace Greenshot.Interop.Office {
/// <summary>
/// Wrapper for Outlook.Application, see: http://msdn.microsoft.com/en-us/library/aa210897%28v=office.11%29.aspx
/// This is the initial COM-Object which is created/retrieved
/// </summary>
[ComProgId("Outlook.Application")]
public interface IOutlookApplication : ICommon {
string Name {
get;
}
string Version {
get;
}
IItem CreateItem(OlItemType ItemType);
object CreateItemFromTemplate(string TemplatePath, object InFolder);
object CreateObject(string ObjectName);
IInspector ActiveInspector();
IInspectors Inspectors {
get;
}
INameSpace GetNameSpace(string type);
IExplorer ActiveExplorer();
IExplorers Explorers {
get;
}
}
/// <summary> /// <summary>
/// See: http://msdn.microsoft.com/en-us/library/bb208387%28v=office.12%29.aspx /// See: http://msdn.microsoft.com/en-us/library/bb208387%28v=office.12%29.aspx
/// </summary> /// </summary>
public interface Items : Collection, IEnumerable { public interface IItems : ICollection, IEnumerable {
Item this[object index] { get; } IItem this[object index] {
Item GetFirst(); get;
Item GetNext(); }
Item GetLast(); IItem GetFirst();
Item GetPrevious(); IItem GetNext();
IItem GetLast();
IItem GetPrevious();
bool IncludeRecurrences { bool IncludeRecurrences {
get; get;
set; set;
} }
Items Restrict(string filter); IItems Restrict(string filter);
void Sort(string property, object descending); void Sort(string property, object descending);
// Actual definition is "object Add( object )", just making it convenient // Actual definition is "object Add( object )", just making it convenient
@ -50,58 +75,137 @@ namespace Greenshot.Interop.Office {
// Common attributes of all the Items (MailItem, AppointmentItem) // Common attributes of all the Items (MailItem, AppointmentItem)
// See: http://msdn.microsoft.com/en-us/library/ff861252.aspx // See: http://msdn.microsoft.com/en-us/library/ff861252.aspx
public interface Item : Common { public interface IItem : ICommon {
Attachments Attachments { get; } IAttachments Attachments {
string Body { get; set; } get;
OlObjectClass Class { get; } }
DateTime CreationTime { get; } string Body {
string EntryID { get; } get;
DateTime LastModificationTime { get; } set;
string MessageClass { get; set; } }
bool NoAging { get; set; } OlObjectClass Class {
int OutlookInternalVersion { get; } get;
string OutlookVersion { get; } }
bool Saved { get; } DateTime CreationTime {
OlSensitivity Sensitivity { get; set; } get;
int Size { get; } }
string Subject { get; set; } string EntryID {
bool UnRead { get; set; } get;
}
DateTime LastModificationTime {
get;
}
string MessageClass {
get;
set;
}
bool NoAging {
get;
set;
}
int OutlookInternalVersion {
get;
}
string OutlookVersion {
get;
}
bool Saved {
get;
}
OlSensitivity Sensitivity {
get;
set;
}
int Size {
get;
}
string Subject {
get;
set;
}
bool UnRead {
get;
set;
}
object Copy(); object Copy();
void Display(bool Modal); void Display(bool Modal);
void Save(); void Save();
PropertyAccessor PropertyAccessor { get; } IPropertyAccessor PropertyAccessor {
Inspector GetInspector(); get;
}
IInspector GetInspector();
} }
// See: http://msdn.microsoft.com/en-us/library/ff861252.aspx // See: http://msdn.microsoft.com/en-us/library/ff861252.aspx
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mailitem.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mailitem.aspx
public interface MailItem : Item, Common { public interface MailItem : IItem, ICommon {
bool Sent { get; } bool Sent {
object MAPIOBJECT { get; } get;
string HTMLBody { get; set; } }
DateTime ExpiryTime { get; set; } object MAPIOBJECT {
DateTime ReceivedTime { get; } get;
string SenderName { get; } }
DateTime SentOn { get; } string HTMLBody {
OlBodyFormat BodyFormat { get; set; } get;
string To { get; set; } set;
string CC { get; set; } }
string BCC { get; set; } DateTime ExpiryTime {
get;
set;
}
DateTime ReceivedTime {
get;
}
string SenderName {
get;
}
DateTime SentOn {
get;
}
OlBodyFormat BodyFormat {
get;
set;
}
string To {
get;
set;
}
string CC {
get;
set;
}
string BCC {
get;
set;
}
} }
// See: http://msdn.microsoft.com/en-us/library/ff869026.aspx // See: http://msdn.microsoft.com/en-us/library/ff869026.aspx
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.appointmentitem.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.appointmentitem.aspx
public interface AppointmentItem : Item, Common { public interface AppointmentItem : IItem, ICommon {
string Organizer { get; set; } string Organizer {
string SendUsingAccount { get; } get;
string Categories { get; } set;
DateTime Start { get; } }
DateTime End { get; } string SendUsingAccount {
OlReoccurenceState RecurrenceState { get; } get;
}
string Categories {
get;
}
DateTime Start {
get;
}
DateTime End {
get;
}
OlReoccurenceState RecurrenceState {
get;
}
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.contactitem.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.contactitem.aspx
public interface ContactItem : Item, Common { public interface IContactItem : IItem, ICommon {
bool HasPicture { bool HasPicture {
get; get;
} }
@ -118,24 +222,37 @@ namespace Greenshot.Interop.Office {
} }
} }
public interface Attachments : Collection { public interface IAttachments : ICollection {
Attachment Add(object source, object type, object position, object displayName); IAttachment Add(object source, object type, object position, object displayName);
// Use index+1!!!! // Use index+1!!!!
Attachment this[object index] { get; } IAttachment this[object index] {
get;
}
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.attachment_members.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.attachment_members.aspx
public interface Attachment : Common { public interface IAttachment : ICommon {
string DisplayName { get; set; } string DisplayName {
string FileName { get; } get;
OlAttachmentType Type { get; } set;
PropertyAccessor PropertyAccessor { get; } }
object MAPIOBJECT { get; } string FileName {
get;
}
OlAttachmentType Type {
get;
}
IPropertyAccessor PropertyAccessor {
get;
}
object MAPIOBJECT {
get;
}
void SaveAsFile(string path); void SaveAsFile(string path);
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.propertyaccessor_members.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.propertyaccessor_members.aspx
public interface PropertyAccessor : Common { public interface IPropertyAccessor : ICommon {
void SetProperty(string SchemaName, Object Value); void SetProperty(string SchemaName, Object Value);
Object GetProperty(string SchemaName); Object GetProperty(string SchemaName);
} }
@ -146,74 +263,128 @@ namespace Greenshot.Interop.Office {
public static class PropTag { public static class PropTag {
public const string ATTACHMENT_CONTENT_ID = @"http://schemas.microsoft.com/mapi/proptag/0x3712001E"; public const string ATTACHMENT_CONTENT_ID = @"http://schemas.microsoft.com/mapi/proptag/0x3712001E";
} }
/// <summary>
/// Wrapper for Outlook.Application, see: http://msdn.microsoft.com/en-us/library/aa210897%28v=office.11%29.aspx
/// </summary>
[ComProgId("Outlook.Application")]
public interface IOutlookApplication : Common {
string Name { get; }
string Version { get; }
Item CreateItem(OlItemType ItemType);
object CreateItemFromTemplate(string TemplatePath, object InFolder);
object CreateObject(string ObjectName);
Inspector ActiveInspector();
Inspectors Inspectors { get; }
INameSpace GetNameSpace(string type);
}
/// <summary> /// <summary>
/// See: http://msdn.microsoft.com/en-us/library/bb176693%28v=office.12%29.aspx /// See: http://msdn.microsoft.com/en-us/library/bb176693%28v=office.12%29.aspx
/// </summary> /// </summary>
public interface INameSpace : Common { public interface INameSpace : ICommon {
IRecipient CurrentUser { get; } IRecipient CurrentUser {
get;
}
IFolder GetDefaultFolder(OlDefaultFolders defaultFolder); IFolder GetDefaultFolder(OlDefaultFolders defaultFolder);
} }
/// <summary> /// <summary>
/// See: http://msdn.microsoft.com/en-us/library/bb176362%28v=office.12%29.aspx /// See: http://msdn.microsoft.com/en-us/library/bb176362%28v=office.12%29.aspx
/// </summary> /// </summary>
public interface IFolder : Common { public interface IFolder : ICommon {
Items Items {get;} IItems Items {
get;
}
} }
public interface IRecipient : Common { public interface IRecipient : ICommon {
string Name { get; } string Name {
get;
}
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.inspector_members.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.inspector_members.aspx
public interface Inspector : Common { public interface IInspector : ICommonExplorer {
Item CurrentItem { get; } IItem CurrentItem {
OlEditorType EditorType { get; } get;
object ModifiedFormPages { get; } }
OlEditorType EditorType {
get;
}
object ModifiedFormPages {
get;
}
void Close(OlInspectorClose SaveMode); void Close(OlInspectorClose SaveMode);
void Display(object Modal); void Display(object Modal);
void HideFormPage(string PageName); void HideFormPage(string PageName);
bool IsWordMail(); bool IsWordMail();
void SetCurrentFormPage(string PageName); void SetCurrentFormPage(string PageName);
void ShowFormPage(string PageName); void ShowFormPage(string PageName);
object HTMLEditor { get; } object HTMLEditor {
IWordDocument WordEditor { get; } get;
string Caption { get; } }
int Height { get; set; } IWordDocument WordEditor {
int Left { get; set; } get;
int Top { get; set; } }
int Width { get; set; }
OlWindowState WindowState { get; set; }
void Activate();
void SetControlItemProperty(object Control, string PropertyName); void SetControlItemProperty(object Control, string PropertyName);
} }
/// <summary>
/// Is a joined interface of the Explorer an Inspector
/// </summary>
public interface ICommonExplorer : ICommon {
void Activate();
string Caption {
get;
}
int Height {
get;
set;
}
int Left {
get;
set;
}
int Top {
get;
set;
}
int Width {
get;
set;
}
OlWindowState WindowState {
get;
set;
}
}
/// <summary>
/// Since Outlook 2010, but since 2013 one can edit inside an explorer
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.explorer_members(v=office.15).aspx
///
/// </summary>
public interface IExplorer : ICommonExplorer {
IItem ActiveInlineResponse {
get;
}
IWordDocument ActiveInlineResponseWordEditor {
get;
}
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._application.inspectors.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._application.inspectors.aspx
public interface Inspectors : Common, Collection, IEnumerable { public interface IInspectors : ICommon, ICollection, IEnumerable {
// Use index + 1!! // Use index + 1!!
Inspector this[Object Index] { get; } IInspector this[Object Index] {
get;
}
}
/// <summary>
/// Since Outlook 2010, but since 2013 one can edit inside an explorer
/// See: http://msdn.microsoft.com/en-us/library/office/ff867227(v=office.15).aspx
/// </summary>
public interface IExplorers : ICommon, ICollection, IEnumerable {
// Use index + 1!!
IExplorer this[Object Index] {
get;
}
} }
/// <summary> /// <summary>
/// Specifies which EmailFormat the email needs to use /// Specifies which EmailFormat the email needs to use
/// </summary> /// </summary>
public enum EmailFormat { public enum EmailFormat {
Text, HTML Text,
HTML
} }
public enum OlBodyFormat { public enum OlBodyFormat {
// Fields // Fields

View file

@ -652,7 +652,7 @@ namespace Greenshot.Interop.Office {
/// </summary> /// </summary>
/// <param name="attachment"></param> /// <param name="attachment"></param>
/// <param name="contentId"></param> /// <param name="contentId"></param>
public static void SetContentID(Attachment attachment, string contentId) { public static void SetContentID(IAttachment attachment, string contentId) {
// Pointer to IUnknown Interface // Pointer to IUnknown Interface
IntPtr IUnknown = IntPtr.Zero; IntPtr IUnknown = IntPtr.Zero;
// Pointer to IMAPIProp Interface // Pointer to IMAPIProp Interface
@ -715,7 +715,7 @@ namespace Greenshot.Interop.Office {
/// <param name="proptag"></param> /// <param name="proptag"></param>
/// <param name="propertyValue"></param> /// <param name="propertyValue"></param>
/// <returns></returns> /// <returns></returns>
public static bool SetMAPIProperty(Attachment attachment, PropTags proptag, string propertyValue) { public static bool SetMAPIProperty(IAttachment attachment, PropTags proptag, string propertyValue) {
// Pointer to IUnknown Interface // Pointer to IUnknown Interface
IntPtr IUnknown = IntPtr.Zero; IntPtr IUnknown = IntPtr.Zero;
// Pointer to IMAPIProp Interface // Pointer to IMAPIProp Interface

View file

@ -23,7 +23,7 @@ using System.Collections;
namespace Greenshot.Interop.Office { namespace Greenshot.Interop.Office {
// See http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.application_members.aspx // See http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.application_members.aspx
[ComProgId("Powerpoint.Application")] [ComProgId("Powerpoint.Application")]
public interface IPowerpointApplication : Common { public interface IPowerpointApplication : ICommon {
IPresentation ActivePresentation { get; } IPresentation ActivePresentation { get; }
IPresentations Presentations { get; } IPresentations Presentations { get; }
bool Visible { get; set; } bool Visible { get; set; }
@ -33,24 +33,24 @@ namespace Greenshot.Interop.Office {
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.slides_members.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.slides_members.aspx
public interface ISlides : Common { public interface ISlides : ICommon {
int Count { get; } int Count { get; }
ISlide Add(int Index, int layout); ISlide Add(int Index, int layout);
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.documentwindow.view.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.documentwindow.view.aspx
public interface IPowerpointWindow : Common { public interface IPowerpointWindow : ICommon {
void Activate(); void Activate();
IPowerpointView View { get; } IPowerpointView View { get; }
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.view_members.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.view_members.aspx
public interface IPowerpointView : Common { public interface IPowerpointView : ICommon {
IZoom Zoom { get; } IZoom Zoom { get; }
void GotoSlide(int index); void GotoSlide(int index);
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.presentation_members.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.presentation_members.aspx
public interface IPresentation : Common { public interface IPresentation : ICommon {
string Name { get; } string Name { get; }
ISlides Slides { get; } ISlides Slides { get; }
IPowerpointApplication Application { get; } IPowerpointApplication Application { get; }
@ -60,19 +60,19 @@ namespace Greenshot.Interop.Office {
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.presentations_members.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.presentations_members.aspx
public interface IPresentations : Common, Collection { public interface IPresentations : ICommon, ICollection {
IPresentation Add(MsoTriState WithWindow); IPresentation Add(MsoTriState WithWindow);
IPresentation item(int index); IPresentation item(int index);
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.pagesetup_members.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.pagesetup_members.aspx
public interface IPageSetup : Common, Collection { public interface IPageSetup : ICommon, ICollection {
float SlideWidth { get; set; } float SlideWidth { get; set; }
float SlideHeight { get; set; } float SlideHeight { get; set; }
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.slide_members.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.slide_members.aspx
public interface ISlide : Common { public interface ISlide : ICommon {
IShapes Shapes { get; } IShapes Shapes { get; }
void Select(); void Select();
int SlideNumber { get; } int SlideNumber { get; }
@ -80,14 +80,14 @@ namespace Greenshot.Interop.Office {
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.shapes_members.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.shapes_members.aspx
public interface IShapes : Common, IEnumerable { public interface IShapes : ICommon, IEnumerable {
int Count { get; } int Count { get; }
IShape item(int index); IShape item(int index);
IShape AddPicture(string FileName, MsoTriState LinkToFile, MsoTriState SaveWithDocument, float Left, float Top, float Width, float Height); IShape AddPicture(string FileName, MsoTriState LinkToFile, MsoTriState SaveWithDocument, float Left, float Top, float Width, float Height);
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.shape_members.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.shape_members.aspx
public interface IShape : Common { public interface IShape : ICommon {
float Left { get; set; } float Left { get; set; }
float Top { get; set; } float Top { get; set; }
float Width { get; set; } float Width { get; set; }
@ -99,11 +99,11 @@ namespace Greenshot.Interop.Office {
MsoTriState LockAspectRatio { get; set; } MsoTriState LockAspectRatio { get; set; }
} }
public interface ITextFrame : Common { public interface ITextFrame : ICommon {
ITextRange TextRange { get; } ITextRange TextRange { get; }
MsoTriState HasText { get; } MsoTriState HasText { get; }
} }
public interface ITextRange : Common { public interface ITextRange : ICommon {
string Text { get; set; } string Text { get; set; }
} }

View file

@ -22,7 +22,7 @@
namespace Greenshot.Interop.Office { namespace Greenshot.Interop.Office {
// See http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.applicationclass_members%28v=Office.11%29.aspx // See http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.applicationclass_members%28v=Office.11%29.aspx
[ComProgId("Word.Application")] [ComProgId("Word.Application")]
public interface IWordApplication : Common { public interface IWordApplication : ICommon {
IWordDocument ActiveDocument { get; } IWordDocument ActiveDocument { get; }
ISelection Selection { get; } ISelection Selection { get; }
IDocuments Documents { get; } IDocuments Documents { get; }
@ -32,7 +32,7 @@ namespace Greenshot.Interop.Office {
} }
// See: http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.documents_members(v=office.11).aspx // See: http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.documents_members(v=office.11).aspx
public interface IDocuments : Common, Collection { public interface IDocuments : ICommon, ICollection {
IWordDocument Add(ref object Template, ref object NewTemplate, ref object DocumentType, ref object Visible); IWordDocument Add(ref object Template, ref object NewTemplate, ref object DocumentType, ref object Visible);
IWordDocument item(int index); IWordDocument item(int index);
} }
@ -40,7 +40,7 @@ namespace Greenshot.Interop.Office {
/// <summary> /// <summary>
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.document%28v=office.14%29.aspx /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.document%28v=office.14%29.aspx
/// </summary> /// </summary>
public interface IWordDocument : Common { public interface IWordDocument : ICommon {
void Activate(); void Activate();
IWordApplication Application { get; } IWordApplication Application { get; }
IWordWindow ActiveWindow { get; } IWordWindow ActiveWindow { get; }
@ -54,7 +54,7 @@ namespace Greenshot.Interop.Office {
/// <summary> /// <summary>
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.window_members.aspx /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.window_members.aspx
/// </summary> /// </summary>
public interface IWordWindow : Common { public interface IWordWindow : ICommon {
IPane ActivePane { get; } IPane ActivePane { get; }
void Activate(); void Activate();
string Caption { string Caption {
@ -65,26 +65,26 @@ namespace Greenshot.Interop.Office {
/// <summary> /// <summary>
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.pane_members.aspx /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.pane_members.aspx
/// </summary> /// </summary>
public interface IPane : Common { public interface IPane : ICommon {
IWordView View { get; } IWordView View { get; }
} }
/// <summary> /// <summary>
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.view_members.aspx /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.view_members.aspx
/// </summary> /// </summary>
public interface IWordView : Common { public interface IWordView : ICommon {
IZoom Zoom { get; } IZoom Zoom { get; }
} }
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.zoom_members.aspx // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.zoom_members.aspx
public interface IZoom : Common { public interface IZoom : ICommon {
int Percentage { get; set; } int Percentage { get; set; }
} }
/// <summary> /// <summary>
/// See: http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.selection_members(v=office.11).aspx /// See: http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.selection_members(v=office.11).aspx
/// </summary> /// </summary>
public interface ISelection : Common { public interface ISelection : ICommon {
IInlineShapes InlineShapes { get; } IInlineShapes InlineShapes { get; }
void InsertAfter(string text); void InsertAfter(string text);
} }
@ -92,14 +92,14 @@ namespace Greenshot.Interop.Office {
/// <summary> /// <summary>
/// See: http://msdn.microsoft.com/en-us/library/ms263866%28v=office.14%29.aspx /// See: http://msdn.microsoft.com/en-us/library/ms263866%28v=office.14%29.aspx
/// </summary> /// </summary>
public interface IInlineShapes : Common { public interface IInlineShapes : ICommon {
IInlineShape AddPicture(string FileName, object LinkToFile, object SaveWithDocument, object Range); IInlineShape AddPicture(string FileName, object LinkToFile, object SaveWithDocument, object Range);
} }
/// <summary> /// <summary>
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.inlineshape_members%28v=office.14%29.aspx /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.inlineshape_members%28v=office.14%29.aspx
/// </summary> /// </summary>
public interface IInlineShape : Common { public interface IInlineShape : ICommon {
IHyperlink Hyperlink { get; } IHyperlink Hyperlink { get; }
MsoTriState LockAspectRatio { MsoTriState LockAspectRatio {
get; get;
@ -110,7 +110,7 @@ namespace Greenshot.Interop.Office {
/// <summary> /// <summary>
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.hyperlink_members%28v=office.14%29.aspx /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.hyperlink_members%28v=office.14%29.aspx
/// </summary> /// </summary>
public interface IHyperlink : Common { public interface IHyperlink : ICommon {
string Address { string Address {
get; get;
set; set;
@ -120,7 +120,7 @@ namespace Greenshot.Interop.Office {
/// <summary> /// <summary>
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.hyperlinks%28v=office.14%29.aspx /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.hyperlinks%28v=office.14%29.aspx
/// </summary> /// </summary>
public interface IHyperlinks : Common, Collection { public interface IHyperlinks : ICommon, ICollection {
IHyperlink Add(object Anchor, object Address, object SubAddress, object ScreenTip, object TextToDisplay, object Target); IHyperlink Add(object Anchor, object Address, object SubAddress, object ScreenTip, object TextToDisplay, object Target);
} }
} }