public void Send(FileItem item, AutoExportPluginConfig configData)
        {
            try
            {
                configData.IsRedy  = false;
                configData.IsError = false;
                var conf = new SendEmailPluginViewModel(configData);

                var outfile = PhotoUtils.ReplaceExtension(Path.GetTempFileName(), Path.GetExtension(item.Name));
                outfile = AutoExportPluginHelper.ExecuteTransformPlugins(item, configData, outfile);

                HelpProvider.SendEmail((string.IsNullOrEmpty(conf.Message) ? "." : conf.TransformTemplate(item, conf.Message)), (string.IsNullOrEmpty(conf.Subject) ? "Your photo" : conf.TransformTemplate(item, conf.Subject)),
                                       conf.From, conf.To, outfile);

                // remove unused file
                if (outfile != item.FileName)
                {
                    PhotoUtils.WaitForFile(outfile);
                    File.Delete(outfile);
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error send email file", exception);
                configData.IsError = true;
                configData.Error   = exception.Message;
            }
            configData.IsRedy = true;
        }
        public void Send(FileItem item, AutoExportPluginConfig configData)
        {
            try
            {
                configData.IsRedy = false;
                configData.IsError = false;
                var conf = new SendEmailPluginViewModel(configData);

                var outfile = PhotoUtils.ReplaceExtension(Path.GetTempFileName(),Path.GetExtension(item.Name));
                outfile = AutoExportPluginHelper.ExecuteTransformPlugins(item, configData, outfile);

                var client = new MailgunClient("digicamcontrol.mailgun.org", "key-6n75wci5cpuz74vsxfcwfkf-t8v74g82",3);
                var message = new MailMessage(conf.From, conf.To)
                {
                    Subject = (string.IsNullOrEmpty(conf.Subject) ? "Your photo":conf.TransformTemplate(item,conf.Subject)),
                    Body = (string.IsNullOrEmpty(conf.Message) ? "." : conf.TransformTemplate(item, conf.Message)),
                    IsBodyHtml = true
                };
                using (MemoryStream stream = new MemoryStream(File.ReadAllBytes(outfile)))
                {
                    message.Attachments.Add(new Attachment(stream, item.Name));

                    client.SendMail(message);
                    message.Dispose();
                }
                // remove unused file
                if (outfile != item.FileName)
                {
                    PhotoUtils.WaitForFile(outfile);
                    File.Delete(outfile);
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error send facebook file", exception);
                configData.IsError = true;
                configData.Error = exception.Message;
            }
            configData.IsRedy = true;
        }
Example #3
0
        public void Send(FileItem item, AutoExportPluginConfig configData)
        {
            try
            {
                var filename = item.FileName;
                configData.IsRedy  = false;
                configData.IsError = false;
                var conf = new SendEmailPluginViewModel(configData);

                var outfile = Path.Combine(Path.GetTempPath(), Path.GetFileName(filename));
                outfile = AutoExportPluginHelper.ExecuteTransformPlugins(item, configData, outfile);

                var client  = new MailgunClient("digicamcontrol.mailgun.org", "key-6n75wci5cpuz74vsxfcwfkf-t8v74g82", 3);
                var message = new MailMessage(conf.From, conf.To)
                {
                    Subject    = (string.IsNullOrEmpty(conf.Subject) ? "Your photo":conf.TransformTemplate(item, conf.Subject)),
                    Body       = (string.IsNullOrEmpty(conf.Message) ? "." : conf.TransformTemplate(item, conf.Message)),
                    IsBodyHtml = true
                };
                message.Attachments.Add(new Attachment(outfile));

                client.SendMail(message);
                message.Dispose();

                // remove unused file
                if (outfile != item.FileName)
                {
                    PhotoUtils.WaitForFile(outfile);
                    File.Delete(outfile);
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error send facebook file", exception);
                configData.IsError = true;
                configData.Error   = exception.Message;
            }
            configData.IsRedy = true;
        }