/// <summary> /// Assigns the with default SMTP box. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <param name="key">The key.</param> public static void AssignWithDefaultSmtpBox(OutgoingEmailServiceType serviceType, int?key) { OutgoingEmailServiceConfigRow row = FindConfigRow(serviceType, key); if (row != null) { row.Delete(); } }
/// <summary> /// Assigns the with SMTP box. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <param name="key">The key.</param> /// <param name="smtpBoxId">The SMTP box id.</param> public static void AssignWithSmtpBox(OutgoingEmailServiceType serviceType, int? key, int smtpBoxId) { OutgoingEmailServiceConfigRow row = FindConfigRow(serviceType, key); if(row==null) { row = new OutgoingEmailServiceConfigRow(); row.ServiceType = (int)serviceType; row.ServiceKey = key; } row.SmtpBoxId = smtpBoxId; row.Update(); }
/// <summary> /// Assigns the with SMTP box. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <param name="key">The key.</param> /// <param name="smtpBoxId">The SMTP box id.</param> public static void AssignWithSmtpBox(OutgoingEmailServiceType serviceType, int?key, int smtpBoxId) { OutgoingEmailServiceConfigRow row = FindConfigRow(serviceType, key); if (row == null) { row = new OutgoingEmailServiceConfigRow(); row.ServiceType = (int)serviceType; row.ServiceKey = key; } row.SmtpBoxId = smtpBoxId; row.Update(); }
/// <summary> /// Finds the config row. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <param name="key">The key.</param> /// <returns></returns> private static OutgoingEmailServiceConfigRow FindConfigRow(OutgoingEmailServiceType serviceType, int?key) { OutgoingEmailServiceConfigRow[] configs = OutgoingEmailServiceConfigRow.List( FilterElement.EqualElement(OutgoingEmailServiceConfigRow.ColumnServiceType, serviceType), key.HasValue ? FilterElement.EqualElement(OutgoingEmailServiceConfigRow.ColumnServiceKey, key): FilterElement.IsNullElement(OutgoingEmailServiceConfigRow.ColumnServiceKey)); if (configs.Length > 0) { return(configs[0]); } return(null); }
/// <summary> /// Finds the Smtp box. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <param name="key">The key.</param> /// <param name="returnDefault">if set to <c>true</c> [return default].</param> /// <returns></returns> public static SmtpBox FindSmtpBox(OutgoingEmailServiceType serviceType, int?key, bool returnDefault) { OutgoingEmailServiceConfigRow config = FindConfigRow(serviceType, key); if (config != null) { return(SmtpBox.Load(config.SmtpBoxId)); } // Return Default if (returnDefault) { return(SmtpBox.GetDefault()); } return(null); }
/// <summary> /// Sends the message. /// </summary> /// <param name="mailFrom">The mail from.</param> /// <param name="rcptTo">The RCPT to.</param> /// <param name="subject">The subject.</param> /// <param name="emlData">The eml data.</param> internal static void SendMessage(OutgoingEmailServiceType serviceType, int?serviceKey, string mailFrom, string rcptTo, string subject, byte[] emlData) { //EmailMessageSmtpQueueRow newOutMsg = new EmailMessageSmtpQueueRow(); //newOutMsg.MailFrom = MailFrom; //newOutMsg.RcptTo = RcptTo; //newOutMsg.Subject = Subject; //newOutMsg.Created = DateTime.UtcNow; //newOutMsg.ErrorMsg = string.Empty; //newOutMsg.Update(); //using (Stream outStream = newOutMsg.GetEmlData(DbContext.Current.Transaction, SqlBlobAccess.Write)) //{ // outStream.Write(EmlData, 0, EmlData.Length); // outStream.Flush(); //} //tran.Commit(); EmailEntity email = BusinessManager.InitializeEntity <EmailEntity>(EmailEntity.ClassName); email.From = mailFrom; email.To = rcptTo; email.Subject = subject; email.MessageContext = System.Text.Encoding.Default.GetString(emlData); email.HtmlBody = string.Empty; // Create Message CreateRequest request = new CreateRequest(email); request.Parameters.Add(OutgoingMessageQueuePlugin.AddToQueue, true); request.Parameters.Add(OutgoingMessageQueuePlugin.SourceName, string.Format("{0}{1}", serviceType, serviceKey.HasValue?(":" + serviceKey.Value.ToString()):"")); BusinessManager.Execute(request); }
/// <summary> /// Finds the SMTP box. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <param name="key">The key.</param> /// <returns></returns> public static SmtpBox FindSmtpBox(OutgoingEmailServiceType serviceType, int? key) { return FindSmtpBox(serviceType, key, true); }
/// <summary> /// Finds the SMTP box. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <param name="returnDefault">if set to <c>true</c> [return default].</param> /// <returns></returns> public static SmtpBox FindSmtpBox(OutgoingEmailServiceType serviceType, bool returnDefault) { return FindSmtpBox(serviceType, null, returnDefault); }
/// <summary> /// Finds the SMTP box. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <returns></returns> public static SmtpBox FindSmtpBox(OutgoingEmailServiceType serviceType) { return FindSmtpBox(serviceType, null, true); }
/// <summary> /// Assigns the with SMTP box. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <param name="smtpBoxId">The SMTP box id.</param> public static void AssignWithSmtpBox(OutgoingEmailServiceType serviceType, int smtpBoxId) { AssignWithSmtpBox(serviceType, null, smtpBoxId); }
/// <summary> /// Assigns the with default SMTP box. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <param name="key">The key.</param> public static void AssignWithDefaultSmtpBox(OutgoingEmailServiceType serviceType, int? key) { OutgoingEmailServiceConfigRow row = FindConfigRow(serviceType, key); if (row != null) row.Delete(); }
/// <summary> /// Finds the SMTP box. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <param name="returnDefault">if set to <c>true</c> [return default].</param> /// <returns></returns> public static SmtpBox FindSmtpBox(OutgoingEmailServiceType serviceType, bool returnDefault) { return(FindSmtpBox(serviceType, null, returnDefault)); }
/// <summary> /// Finds the SMTP box. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <returns></returns> public static SmtpBox FindSmtpBox(OutgoingEmailServiceType serviceType) { return(FindSmtpBox(serviceType, null, true)); }
/// <summary> /// Finds the Smtp box. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <param name="key">The key.</param> /// <param name="returnDefault">if set to <c>true</c> [return default].</param> /// <returns></returns> public static SmtpBox FindSmtpBox(OutgoingEmailServiceType serviceType, int? key, bool returnDefault) { OutgoingEmailServiceConfigRow config = FindConfigRow(serviceType, key); if (config!=null) { return SmtpBox.Load(config.SmtpBoxId); } // Return Default if(returnDefault) return SmtpBox.GetDefault(); return null; }
/// <summary> /// Finds the config row. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <param name="key">The key.</param> /// <returns></returns> private static OutgoingEmailServiceConfigRow FindConfigRow(OutgoingEmailServiceType serviceType, int? key) { OutgoingEmailServiceConfigRow[] configs = OutgoingEmailServiceConfigRow.List( FilterElement.EqualElement(OutgoingEmailServiceConfigRow.ColumnServiceType, serviceType), key.HasValue ? FilterElement.EqualElement(OutgoingEmailServiceConfigRow.ColumnServiceKey, key): FilterElement.IsNullElement(OutgoingEmailServiceConfigRow.ColumnServiceKey)); if (configs.Length > 0) return configs[0]; return null; }
/// <summary> /// Finds the SMTP box. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <param name="key">The key.</param> /// <returns></returns> public static SmtpBox FindSmtpBox(OutgoingEmailServiceType serviceType, int?key) { return(FindSmtpBox(serviceType, key, true)); }