示例#1
0
        public void AttachFiles(IAttach attacher)
        {
            var files = new List <string>();

            if (_config.FilesToAttach.Length > 0)
            {
                files.AddRange(_config.FilesToAttach);
            }
            if (_config.ScreenshotAvailable)
            {
                files.Add(ScreenshotTaker.GetImageAsFile(_config.ScreenshotImage));
            }

            var filesThatExist = files.Where(f => File.Exists(f)).ToList();

            // attach external zip files separately - admittedly weak detection using just file extension
            filesThatExist.Where(f => f.EndsWith(ZIP)).ToList().ForEach(attacher.Attach);

            // now zip & attach all specified files (ie config FilesToAttach) plus screenshot, if taken
            var filesToZip = filesThatExist.Where(f => !f.EndsWith(ZIP)).ToList();

            if (filesToZip.Any())
            {
                var zipFile = File.TempFile(_config.AttachmentFilename);
                Zipper.Zip(zipFile, filesToZip);
                attacher.Attach(zipFile);
            }
        }
 public OutlookController(IAttach _attach)
 {
     this.attach = _attach;
 }
 public GmailController(IAttach _attach)
 {
     this.attach = _attach;
 }