/// <summary> /// Send an email to the specified recipient group containing details of the issues in this list. /// </summary> /// <param name="recipientGroup">The name of the recipient group as defined in your program's Recipients.xml file.</param> /// <param name="log">Log file to attach with further details.</param> /// <param name="attachmentFilepaths">Any additional files to attach.</param> /// <param name="useOpeners">If true, the body of the email will be preceded by comedic openers.</param> public void Send(string recipientGroup, bool useOpeners = true, Log log = null, IEnumerable <string> attachmentFilepaths = null) { RecipientList group = RecipientList.Get(recipientGroup); if (group == null) { throw new ArgumentException("\"" + recipientGroup + "\" is not a valid recipient group."); } Send(group, log ?? Log, useOpeners, attachmentFilepaths); }
/// <summary> /// Get all groups as defined in a file. /// </summary> /// <param name="filepath">The path to the XML file containing the groups. Default: Recipients.xml in current folder.</param> /// <returns>A List of RecipientLists that represent all groups defined in the specified file.</returns> public static List <RecipientList> GetAllGroups(string filepath = null) { List <RecipientList> groups = new List <RecipientList>(); XMLFile file = new XMLFile(filepath ?? Path.Combine(Directory.GetCurrentDirectory(), "Recipients.xml")); foreach (XMLSection section in file.FindSection("groups").GetSections()) { RecipientList recipients = new RecipientList(section.Get("name")); foreach (XMLNode node in section.FindSection("recipients").Children) { recipients.Add(node.Get()); } groups.Add(recipients); } return(groups); }
/// <summary> /// Send an email to a specified email group. /// </summary> /// <param name="from">The email address from which the email is sent.</param> /// <param name="groupName">The email group to which the email will be sent, as defined in your program's Recipients.xml file.</param> /// <param name="subject">The text to go in the subject line of the email.</param> /// <param name="message">The text to go in the body of the email.</param> /// <param name="log">The Log file to send.</param> /// <param name="useOpeners">If true, the email body will be preceded by comedic openers.</param> /// <param name="attachmentFilepaths">An array containing the filepaths of the attachments.</param> /// <param name="isHtml">If true, the email will be sent as HTML, else plain text.</param> public static void SendEmail(string from, string groupName, string subject, string message, Log log = null, bool useOpeners = false, IEnumerable <string> attachmentFilepaths = null, bool isHtml = false) { SendEmail(from, RecipientList.Get(groupName), subject, message, log, useOpeners, attachmentFilepaths, isHtml); }