Example #1
0
        /// <summary>
        /// Export the capture to outlook
        /// </summary>
        /// <param name="manuallyInitiated"></param>
        /// <param name="surface"></param>
        /// <param name="captureDetails"></param>
        /// <returns></returns>
        public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
            // Outlook logic
            string tmpFile = captureDetails.Filename;

            if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$"))
            {
                tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());
            }
            else
            {
                LOG.InfoFormat("Using already available file: {0}", tmpFile);
            }

            // Create a attachment name for the image
            string attachmentName = captureDetails.Title;

            if (!string.IsNullOrEmpty(attachmentName))
            {
                attachmentName = attachmentName.Trim();
            }
            // Set default if non is set
            if (string.IsNullOrEmpty(attachmentName))
            {
                attachmentName = "Greenshot Capture";
            }
            // Make sure it's "clean" so it doesn't corrupt the header
            attachmentName = Regex.Replace(attachmentName, @"[^\x20\d\w]", "");

            if (outlookInspectorCaption != null)
            {
                OutlookEmailExporter.ExportToInspector(outlookInspectorCaption, tmpFile, attachmentName);
                exportInformation.ExportMade = true;
            }
            else
            {
                if (!manuallyInitiated)
                {
                    IDictionary <string, OlObjectClass> inspectorCaptions = OutlookEmailExporter.RetrievePossibleTargets();
                    if (inspectorCaptions != null && inspectorCaptions.Count > 0)
                    {
                        List <IDestination> destinations = new List <IDestination>();
                        destinations.Add(new OutlookDestination());
                        foreach (string inspectorCaption in inspectorCaptions.Keys)
                        {
                            destinations.Add(new OutlookDestination(inspectorCaption, inspectorCaptions[inspectorCaption]));
                        }
                        // Return the ExportInformation from the picker without processing, as this indirectly comes from us self
                        return(ShowPickerMenu(false, surface, captureDetails, destinations));
                    }
                }
                else
                {
                    exportInformation.ExportMade = OutlookEmailExporter.ExportToOutlook(conf.OutlookEmailFormat, tmpFile, FilenameHelper.FillPattern(conf.EmailSubjectPattern, captureDetails, false), attachmentName, conf.EmailTo, conf.EmailCC, conf.EmailBCC, null);
                }
            }
            ProcessExport(exportInformation, surface);
            return(exportInformation);
        }
Example #2
0
        public override IEnumerable <IDestination> DynamicDestinations()
        {
            IDictionary <string, OlObjectClass> inspectorCaptions = OutlookEmailExporter.RetrievePossibleTargets();

            if (inspectorCaptions != null)
            {
                foreach (string inspectorCaption in inspectorCaptions.Keys)
                {
                    yield return(new OutlookDestination(inspectorCaption, inspectorCaptions[inspectorCaption]));
                }
            }
        }
Example #3
0
        public override IEnumerable <IDestination> DynamicDestinations()
        {
            var inspectorCaptions = OutlookEmailExporter.RetrievePossibleTargets();

            if (inspectorCaptions == null)
            {
                yield break;
            }
            foreach (var inspectorCaption in inspectorCaptions.Keys)
            {
                yield return(new OutlookDestination(inspectorCaption, inspectorCaptions[inspectorCaption], _officeConfiguration, CoreConfiguration, GreenshotLanguage));
            }
        }
        public override IEnumerable <IDestination> DynamicDestinations()
        {
            if (!isOutlookUsed)
            {
                yield break;
            }
            Dictionary <string, OlObjectClass> inspectorCaptions = OutlookEmailExporter.RetrievePossibleTargets(conf.OutlookAllowExportInMeetings);

            if (inspectorCaptions != null)
            {
                foreach (string inspectorCaption in inspectorCaptions.Keys)
                {
                    yield return(new EmailDestination(inspectorCaption, inspectorCaptions[inspectorCaption]));
                }
            }
        }
        public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            if (!isOutlookUsed)
            {
                using (Image image = surface.GetImageForExport()) {
                    MapiMailMessage.SendImage(image, captureDetails);
                    surface.Modified = false;
                    surface.SendMessageEvent(this, SurfaceMessageTyp.Info, "Exported to " + mapiClient);
                }
                return(true);
            }

            // Outlook logic
            string tmpFile = captureDetails.Filename;

            if (tmpFile == null || surface.Modified)
            {
                using (Image image = surface.GetImageForExport()) {
                    tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality, conf.OutputFileReduceColors);
                }
            }
            else
            {
                LOG.InfoFormat("Using already available file: {0}", tmpFile);
            }

            // Create a attachment name for the image
            string attachmentName = captureDetails.Title;

            if (!string.IsNullOrEmpty(attachmentName))
            {
                attachmentName = attachmentName.Trim();
            }
            // Set default if non is set
            if (string.IsNullOrEmpty(attachmentName))
            {
                attachmentName = "Greenshot Capture";
            }
            // Make sure it's "clean" so it doesn't corrupt the header
            attachmentName = Regex.Replace(attachmentName, @"[^\x20\d\w]", "");

            if (outlookInspectorCaption != null)
            {
                OutlookEmailExporter.ExportToInspector(outlookInspectorCaption, tmpFile, attachmentName);
            }
            else
            {
                if (!manuallyInitiated)
                {
                    Dictionary <string, OlObjectClass> inspectorCaptions = OutlookEmailExporter.RetrievePossibleTargets(conf.OutlookAllowExportInMeetings);
                    if (inspectorCaptions != null && inspectorCaptions.Count > 0)
                    {
                        List <IDestination> destinations = new List <IDestination>();
                        destinations.Add(new EmailDestination());
                        foreach (string inspectorCaption in inspectorCaptions.Keys)
                        {
                            destinations.Add(new EmailDestination(inspectorCaption, inspectorCaptions[inspectorCaption]));
                        }
                        ContextMenuStrip menu = PickerDestination.CreatePickerMenu(false, surface, captureDetails, destinations);
                        PickerDestination.ShowMenuAtCursor(menu);
                        return(false);
                    }
                }
                OutlookEmailExporter.ExportToOutlook(conf.OutlookEmailFormat, tmpFile, captureDetails.Title, attachmentName);
            }
            surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString(LangKey.exported_to, Description));
            surface.Modified = false;

            // Don't know how to handle a cancel in the email

            return(true);
        }