public void EmailAutomation()
 {
     using (var context = new SidejobEntities())
     {
         var message = (from c in context.AutomatedMessages
                        select c).ToList();
         if (message.Count != 0)
         {
             foreach (var e in message)
             {
                 try
                 {
                     SendEmail(e.EmailAddress, e.Title, e.MessageID.ToString(CultureInfo.InvariantCulture), Server.MapPath("~/EmailTemplates/AutomatedMessage.aspx"), Message.Automated);
                 }
                 catch (Exception emailexception)
                 {
                     var emailProblem = new AutomationEmailProblem
                                            {
                                                MessageID = e.MessageID,
                                                EmailAddress = e.EmailAddress,
                                                Title = e.Title,
                                                Message = e.Message
                                            };
                     context.AddToAutomationEmailProblems(emailProblem);
                 }
             }
         }
         context.DeleteObject(message);
         context.SaveChanges();
     }
 }
示例#2
0
 public void CatchMessage(SidejobEntities context, AutomatedMessage m)
 {
     var messageProblem = new AutomationEmailProblem
     {
         MessageID = m.MessageID,
         EmailAddress = m.EmailAddress,
         Title = m.Title,
         Message = m.Message
     };
     context.AddToAutomationEmailProblems(messageProblem);
     context.SaveChanges();
 }
示例#3
0
 public void CatchMessage(string id)
 {
     using (var context = new SidejobEntities())
     {
         var messageProblem = new AutomationEmailProblem
                                  {
                                      MessageID = GetMessageID(context),
                                      EmailAddress = "From Sending Message",
                                      Title = "Go Find It",
                                      Message ="Check AutomatedMessageTable"
                                  };
         context.AddToAutomationEmailProblems(messageProblem);
         context.SaveChanges();
     }
 }
 /// <summary>
 /// Create a new AutomationEmailProblem object.
 /// </summary>
 /// <param name="messageID">Initial value of the MessageID property.</param>
 public static AutomationEmailProblem CreateAutomationEmailProblem(global::System.Int32 messageID)
 {
     AutomationEmailProblem automationEmailProblem = new AutomationEmailProblem();
     automationEmailProblem.MessageID = messageID;
     return automationEmailProblem;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the AutomationEmailProblems EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAutomationEmailProblems(AutomationEmailProblem automationEmailProblem)
 {
     base.AddObject("AutomationEmailProblems", automationEmailProblem);
 }