public SmtpClient CreateSmtpClient(IMsgContext msgContext) { var smtpClient = new SmtpClient(); smtpClient.Host = msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_HOST); smtpClient.Port = Convert.ToInt32(msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_PORT)); smtpClient.EnableSsl = msgContext.GetConfigValue(IFConfigPropertyNames.SMTP_ENABLESSL, false); smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = new NetworkCredential(msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_FROM), msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_PASSWORD)); return(smtpClient); }
public void Send(IMsgContext msgContext) { try { var smtpClient = CreateSmtpClient(msgContext); var mailMessage = GenerateMailMessage(msgContext); smtpClient.Send(mailMessage); } catch (Exception) { throw; } }
private void validate_it_is_not_a_merge(IMsgContext prev, IMsgContext next, object msg) { if (prev == null) return; if (ReferenceEquals(prev, Null.MsgContext)) return; if (ReferenceEquals(prev, next)) return; throw new MsgIsTheAppException( "Merging of two applications is not supported; '{0}' {1}", msg.GetType().Name, msg.ToJson()); }
public MailMessage GenerateMailMessage(IMsgContext msgContext) { var messageFromAddress = msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_FROM); var messageToAddresses = msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_TO); var messageFrom = new MailAddress(messageFromAddress); var messageTo = new MailAddress(messageToAddresses); var message = new MailMessage(messageFrom, messageTo); message.CC.Add(messageFrom); message.Subject = msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_SUBJECT); message.Body = msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.SMTP_BODY); message.Attachments.Add(AddAttachment(msgContext)); return(message); }
void IMsgIsTheApp.SetContextFor(MsgContext access, IMsgContext context, object msg) { Validate.NotNull(access); MsgContextProxy prev; _contexts.TryGetValue(msg, out prev); if (prev != null) { validate_it_is_not_a_merge(prev.Impl, context.Impl, msg); return; } var proxy = new MsgContextProxy(context); proxy.SetMsgIsTheApp(this); try { _contexts.Add(msg, proxy); } catch (ArgumentException) // key already exists {} }
public IMessageAction Process(IMsgContext msgContext) { return(MessageAction.ContinueProcessing); }
public IMessageAction Process(IMsgContext msgContext) { MailService.Send(msgContext); return(MessageAction.ContinueProcessing); }
public Attachment AddAttachment(IMsgContext msgContext) { return(new Attachment(msgContext.GetMsgOrConfigValue(IFConfigPropertyNames.FILE_PATH), MediaTypeNames.Application.Octet)); }
public RabbitConsumer(IMsgContext <IModel> context) { _context = context; }
public RabbitProducer(IMsgContext <IModel> context) { _context = context; }
IMessageAction IFComponent.Process(IMsgContext msgContext) { //This is a listner throw new NotImplementedException(); }