Beispiel #1
0
        /// <summary>
        ///     build email HTML content
        /// </summary>
        /// <param name="map">content map</param>
        /// <param name="greeting">Dear balblabla,</param>
        /// <param name="salution">Regards,</param>
        /// <returns></returns>
        public string BuildContent(ContentMap map, string greeting, string salution)
        {
            //int rowCount = 0;
            //int occurrent = CountOccurrent(headerIndex, uniqueName);
            //insert HTML defination, table headers
            var builder = new StringBuilder();

            builder.Append("<html>").Append(_openHeadHtml).Append("<body>");
            //insert greeting
            if (!string.IsNullOrEmpty(greeting))
            {
                builder.Append(greeting);
            }
            //insert header
            builder.Append("<table>");
            builder.Append(BuildHeadersHtml());

            //row iteration
            foreach (int rowIndex in map.Map)
            {
                builder.Append("<tr>");
                for (int colIndex = 0; colIndex <= LastColIndex; colIndex++) //loop Y axis
                {
                    string cellContent = _content[rowIndex, colIndex] ?? string.Empty;
                    builder.Append(string.Format("<td>{0}</td>", cellContent));
                }
                builder.Append("</tr>");
                //rowCount++;
            }
            //close table
            builder.Append("</table>");
            //insert salution
            if (!string.IsNullOrEmpty(salution))
            {
                builder.Append(salution);
            }
            //close body & html
            builder.Append("</body>").Append("</html>");
            return(builder.ToString());
        }
Beispiel #2
0
        /// <summary>
        ///     build recipient list
        /// </summary>
        /// <param name="headers">columns to get more recipients ex: "rep1; rep2"</param>
        /// <returns></returns>
        public List <string> BuildAdditionalRecipients(string headers, ContentMap map)
        {
            if (headers == string.Empty)
            {
                return(new List <string>());
            }
            var emailList    = new List <string>();
            var colIndexList = new List <int>();
            var split        = headers.Split(';');

            foreach (string header in split)
            {
                if (header == string.Empty)
                {
                    continue;
                }
                int headerIndex = FindHeaderIndex(header.Trim());
                if (headerIndex == -1)
                {
                    Logger.Log(string.Format("Could not find header: {0}", header));
                    continue;
                }
                colIndexList.Add(headerIndex);
            }
            foreach (int colIndex in colIndexList)
            {
                foreach (int rowIndex in map.Map)
                {
                    string email = _content[rowIndex, colIndex].Trim();
                    if (!emailList.Contains(email) && email != string.Empty)
                    {
                        emailList.Add(email);
                    }
                }
            }
            return(emailList);
        }