/// <summary> /// Helper Method for creating an Email with Image Attachment /// </summary> /// <param name="image">The image to send</param> /// <param name="captureDetails">ICaptureDetails</param> public static void SendImage(ISurface surface, ICaptureDetails captureDetails) { string tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings()); if (tmpFile != null) { // Store the list of currently active windows, so we can make sure we show the email window later! List <WindowDetails> windowsBefore = WindowDetails.GetVisibleWindows(); // Fallback to MAPI // Send the email SendImage(tmpFile, captureDetails); WindowDetails.ActiveNewerWindows(windowsBefore); } }
/// <summary> /// Helper Method for creating an Email with Image Attachment /// </summary> /// <param name="image">The image to send</param> /// <param name="captureDetails">ICaptureDetails</param> public static void SendImage(Image image, ICaptureDetails captureDetails) { string pattern = conf.OutputFileFilenamePattern; if (pattern == null || string.IsNullOrEmpty(pattern.Trim())) { pattern = "greenshot ${capturetime}"; } string filename = FilenameHelper.GetFilenameFromPattern(pattern, conf.OutputFileFormat, captureDetails); // Prevent problems with "other characters", which causes a problem in e.g. Outlook 2007 or break our HTML filename = Regex.Replace(filename, @"[^\d\w\.]", "_"); // Remove multiple "_" filename = Regex.Replace(filename, @"_+", "_"); string tmpFile = Path.Combine(Path.GetTempPath(), filename); LOG.Debug("Creating TMP File for Email: " + tmpFile); // Catching any exception to prevent that the user can't write in the directory. // This is done for e.g. bugs #2974608, #2963943, #2816163, #2795317, #2789218 try { ImageOutput.Save(image, tmpFile, true, conf.OutputFileJpegQuality, false); } catch (Exception e) { // Show the problem MessageBox.Show(e.Message, "Error"); // when save failed we present a SaveWithDialog tmpFile = ImageOutput.SaveWithDialog(image, captureDetails); } if (tmpFile != null) { // Store the list of currently active windows, so we can make sure we show the email window later! List <WindowDetails> windowsBefore = WindowDetails.GetVisibleWindows(); bool isEmailSend = false; if (EmailConfigHelper.HasOutlook() && (conf.OutputEMailFormat == EmailFormat.OUTLOOK_HTML || conf.OutputEMailFormat == EmailFormat.OUTLOOK_TXT)) { isEmailSend = OutlookExporter.ExportToOutlook(tmpFile, captureDetails); } if (!isEmailSend && EmailConfigHelper.HasMAPI()) { // Fallback to MAPI // Send the email and Cleanup the tmp files on exit SendImage(tmpFile, captureDetails.Title, true); } WindowDetails.ActiveNewerWindows(windowsBefore); } }
/// <summary> /// Helper Method for creating an Email with Image Attachment /// </summary> /// <param name="surface">The image to send</param> /// <param name="captureDetails">ICaptureDetails</param> public static void SendImage(ISurface surface, ICaptureDetails captureDetails) { string tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings()); if (tmpFile != null) { // Store the list of currently active windows, so we can make sure we show the email window later! var windowsBefore = WindowDetails.GetVisibleWindows(); //bool isEmailSend = false; //if (EmailConfigHelper.HasOutlook() && (CoreConfig.OutputEMailFormat == EmailFormat.OUTLOOK_HTML || CoreConfig.OutputEMailFormat == EmailFormat.OUTLOOK_TXT)) { // isEmailSend = OutlookExporter.ExportToOutlook(tmpFile, captureDetails); //} if (/*!isEmailSend &&*/ EmailConfigHelper.HasMapi()) { // Fallback to MAPI // Send the email SendImage(tmpFile, captureDetails.Title); } WindowDetails.ActiveNewerWindows(windowsBefore); } }
/// <summary> /// Helper Method for creating an Email with Image Attachment /// </summary> /// <param name="image">The image to send</param> /// <param name="captureDetails">ICaptureDetails</param> public static void SendImage(Image image, ICaptureDetails captureDetails) { string tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality, conf.OutputFileReduceColors); if (tmpFile != null) { // Store the list of currently active windows, so we can make sure we show the email window later! List <WindowDetails> windowsBefore = WindowDetails.GetVisibleWindows(); bool isEmailSend = false; //if (EmailConfigHelper.HasOutlook() && (conf.OutputEMailFormat == EmailFormat.OUTLOOK_HTML || conf.OutputEMailFormat == EmailFormat.OUTLOOK_TXT)) { // isEmailSend = OutlookExporter.ExportToOutlook(tmpFile, captureDetails); //} if (!isEmailSend && EmailConfigHelper.HasMAPI()) { // Fallback to MAPI // Send the email SendImage(tmpFile, captureDetails.Title); } WindowDetails.ActiveNewerWindows(windowsBefore); } }