Example #1
0
        private static EmailMessageExts ParseMailConversations(MailConversations mc)
        {
            EmailMessageExts emes = new EmailMessageExts();

            log.Info("extracting mail information....");

            foreach (string key in mc.conversations.Keys)
            {
                foreach (EmailMessage mm in mc.conversations[key])
                {
                    HtmlDocument doc = new HtmlDocument();

                    doc.LoadHtml(mm.Body);

                    EmailMessageExt eme;


                    HtmlNodeCollection allTablesInOneMail = doc.DocumentNode.SelectNodes("//table");

                    //find the last table in the mail chain
                    //logically the table is in the first mail, so it usually at the bottom a mail html
                    if (allTablesInOneMail != null)
                    {
                        if (allTablesInOneMail.Count > 0)
                        {
                            HtmlNode           table = allTablesInOneMail[allTablesInOneMail.Count - 1];
                            HtmlNodeCollection rows  = table.SelectNodes("tbody/tr");

                            if (rows[0].InnerText.Replace(" ", "").Trim() == matchTableHeader.Replace(" ", "").Trim())
                            {
                                //row[0] = "Power BI Social Media Escalation"
                                //row[1] = date
                                //row[2] = url
                                //row[3] = question body
                                eme = new EmailMessageExt(mm, rows[1].InnerText.Trim(), rows[2].InnerText.Trim(), rows[3].InnerText.Trim());
                            }
                            else
                            {
                                eme = new EmailMessageExt(mm, null, null, null);
                            }

                            emes.emailMessageExts.Add(eme);
                        }
                    }
                }
            }

            return(emes.emailMessageExts.Count == 0 ? null : emes);
        }
Example #2
0
        // Note that for this sample, the ExchangeVersion is hard-coded in UserData.cs to ExchangeVersion.Exchange2013.
        static void Main(string[] args)
        {
            FindItemsResults <Item> results = FindItems(service);

            if (results.TotalCount > 0)
            {
                MailConversations mc = extractItems(results);

                if (mc != null)
                {
                    EmailMessageExts emes = ParseMailConversations(mc);

                    if (emes != null)
                    {
                        //Console.WriteLine(Utils.XmlObjectUtil.GetXMLFromObject(emes.emailMessageExts[0]));

                        DBUtil.insertIntoDB(emes);

                        /** foreach (EmailMessageExt eme in emes.emailMessageExts) {
                         *
                         *   Console.WriteLine(eme.threadCreatedDateTime);
                         *   Console.WriteLine(eme.threadUrl);
                         *   Console.WriteLine(eme.question);
                         *
                         * } **/
                    }
                }
            }

            try
            {
                /**
                 * MailUtil mu = new MailUtil();
                 * mu.sendmail("test","test");
                 **/
            }

            catch (Exception ex)
            {
                log.Error("Error", ex);
            }

            //mu.sendmail("","");

            Console.WriteLine("\r\n");
            Console.WriteLine("Press or select Enter...");
            Console.Read();
        }
Example #3
0
 private static void saveMailConversationInDB(EmailMessageExts emes)
 {
     throw new NotImplementedException();
 }