示例#1
0
 public void SendMessage(EmailMsgOut msg)
 {
     lock (this)
     {
         if (!Directory.Exists(TempDir)) Directory.CreateDirectory(TempDir);
     }
     string fn = Guid.NewGuid().ToString("N") + ".txt";
     string bodyFile = Path.Combine(TempDir, fn);
     using (StreamWriter sw = new StreamWriter(bodyFile, false, Encoding.UTF8))
     {
         sw.Write(msg.Body);
     }
     string arguments = string.Format("\"{0}\" -to \"{1}\" -subject \"{2}\" {3}", bodyFile, msg.Recipients, msg.Subject, CmdLine);
     log.Info("Blat commandline: {0} {1}", ExePath, arguments);
     ProcessStartInfo psi = new ProcessStartInfo(ExePath, arguments);
     using (Process p = Process.Start(psi))
     {
         p.WaitForExit();
         log.Info("Email sent");
     }
 }
 protected override void DoInitiateTask()
 {
     EmailMsgOut msg = new EmailMsgOut();
     msg.CorrelationId = this.CorrelationId;
     msg.Recipients = this.Recipients;
     msg.Subject = this.Subject;
     msg.Body = this.Body;
     //SMTPEmailSender sender;
     //Spring.Context.IApplicationContext ctx = Spring.Context.Support.ContextRegistry.GetContext();
     //sender = (SMTPEmailSender) ctx.GetObject(SenderName);
     //sender.SendMessage(msg);
     //OnTaskCompleted();
     _msgid = Context.EnvironmentContext.MessageBus.NotifyAsync("NotificationTaskActive." + CorrelationId, "SendEmail." + this.SenderName, msg);
     log.Debug("Message sent: {0}", _msgid);
 }