diff --git a/Greenshot/Destinations/EmailDestination.cs b/Greenshot/Destinations/EmailDestination.cs index 41162f690..0c0ae530e 100644 --- a/Greenshot/Destinations/EmailDestination.cs +++ b/Greenshot/Destinations/EmailDestination.cs @@ -223,7 +223,7 @@ namespace Greenshot.Destinations { return false; } } - OutlookEmailExporter.ExportToOutlook(conf.OutlookEmailFormat, tmpFile, captureDetails.Title, attachmentName); + OutlookEmailExporter.ExportToOutlook(conf.OutlookEmailFormat, tmpFile, FilenameHelper.FillPattern(conf.EmailSubjectPattern, captureDetails, false), attachmentName, conf.EmailTo, conf.EmailCC, conf.EmailBCC); } surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString(LangKey.exported_to, Description)); surface.Modified = false; diff --git a/GreenshotInterop/OfficeExport/OutlookEmailExporter.cs b/GreenshotInterop/OfficeExport/OutlookEmailExporter.cs index ba3050617..de143b2c2 100644 --- a/GreenshotInterop/OfficeExport/OutlookEmailExporter.cs +++ b/GreenshotInterop/OfficeExport/OutlookEmailExporter.cs @@ -283,7 +283,7 @@ namespace Greenshot.Interop.Office { /// /// /// - private static void ExportToNewEmail(IOutlookApplication outlookApplication, EmailFormat format, string tmpFile, string subject, string attachmentName) { + private static void ExportToNewEmail(IOutlookApplication outlookApplication, EmailFormat format, string tmpFile, string subject, string attachmentName, string to, string CC, string BCC) { Item newItem = outlookApplication.CreateItem(OlItemType.olMailItem); if (newItem == null) { return; @@ -291,7 +291,16 @@ namespace Greenshot.Interop.Office { //MailItem newMail = COMWrapper.Cast(newItem); MailItem newMail = (MailItem)newItem; newMail.Subject = subject; - newMail.BodyFormat = OlBodyFormat.olFormatHTML; + if (string.IsNullOrEmpty(to)) { + newMail.To = to; + } + if (string.IsNullOrEmpty(CC)) { + newMail.CC = CC; + } + if (string.IsNullOrEmpty(BCC)) { + newMail.BCC = BCC; + } + newMail.BodyFormat = OlBodyFormat.olFormatHTML; string bodyString = null; // Read the default signature, if nothing found use empty email try { @@ -384,12 +393,12 @@ namespace Greenshot.Interop.Office { /// /// The file to send, do not delete the file right away! /// true if it worked, false if not - public static bool ExportToOutlook(EmailFormat format, string tmpFile, string subject, string attachmentName) { + public static bool ExportToOutlook(EmailFormat format, string tmpFile, string subject, string attachmentName, string to, string CC, string BCC) { bool exported = false; try { using (IOutlookApplication outlookApplication = GetOrCreateOutlookApplication()) { if (outlookApplication != null) { - ExportToNewEmail(outlookApplication, format, tmpFile, subject, attachmentName); + ExportToNewEmail(outlookApplication, format, tmpFile, subject, attachmentName, to, CC, BCC); exported = true; } } diff --git a/GreenshotInterop/OfficeInterop/OutlookInterop.cs b/GreenshotInterop/OfficeInterop/OutlookInterop.cs index 65c395cc2..adbd0aefd 100644 --- a/GreenshotInterop/OfficeInterop/OutlookInterop.cs +++ b/GreenshotInterop/OfficeInterop/OutlookInterop.cs @@ -85,7 +85,10 @@ namespace Greenshot.Interop.Office { 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/microsoft.office.interop.outlook.appointmentitem.aspx diff --git a/GreenshotPlugin/Core/CoreConfiguration.cs b/GreenshotPlugin/Core/CoreConfiguration.cs index 440950dd1..fb81448da 100644 --- a/GreenshotPlugin/Core/CoreConfiguration.cs +++ b/GreenshotPlugin/Core/CoreConfiguration.cs @@ -103,7 +103,15 @@ namespace GreenshotPlugin.Core { [IniProperty("OutlookEmailFormat", Description = "Default type for emails. (Text, HTML)", DefaultValue="HTML")] public EmailFormat OutlookEmailFormat; - [IniProperty("OutlookAllowExportInMeetings", Description = "Allow export in meeting items", DefaultValue="False")] + [IniProperty("EmailSubjectPattern", Description = "Email subject pattern, works like the OutputFileFilenamePattern", DefaultValue = "${title}")] + public string EmailSubjectPattern; + [IniProperty("EmailTo", Description = "Default value for the to", DefaultValue = "")] + public string EmailTo; + [IniProperty("EmailCC", Description = "Default value for the CC", DefaultValue = "")] + public string EmailCC; + [IniProperty("EmailBCC", Description = "Default value for the BCC", DefaultValue = "")] + public string EmailBCC; + [IniProperty("OutlookAllowExportInMeetings", Description = "Allow export in meeting items", DefaultValue = "False")] public bool OutlookAllowExportInMeetings; [IniProperty("OutputFileCopyPathToClipboard", Description="When saving a screenshot, copy the path to the clipboard?", DefaultValue="true")]