Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET IMAP

 AfterLogic Forum : MailBee.NET IMAP
Subject Topic: HTML emails Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Jangla
Newbie
Newbie


Joined: 18 June 2007
Location: United Kingdom
Online Status: Offline
Posts: 9
Posted: 19 June 2007 at 4:31am | IP Logged Quote Jangla

If I'm using the IMPA component to grab and email which is known to be formatted in HTML, is there any way of easily stripping the data out ready to be added to a database?

The email comes in as an html table like this:

FIRST_NAME     Bilbo
SURNAME     Baggins
EMAIL     bilbo@email.com
TELEPHONE     0800 666 6666
COMMENTS     Hi Bilbo,
I'm just testing the email system for you.
Could you let me know if you receive this by sending an email to bilbo@email.com please?

What I'd like to do is to be able to grab the first name, surname etc. and add them to a database without having to parse the email like it was a standard string. So I guess my question is can I examine the HTML elements within an email usng the component or am I gong to have to stick to using a whole series of IndexOf statements to get rid of the bits I don't need?
Back to Top View Jangla's Profile Search for other posts by Jangla
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 19 June 2007 at 8:51am | IP Logged Quote Alex

Parsing HTML will be introduced in MailBee.NET Objects v3.0. It's not published yet since the documentation is not ready yet but you can get the dll itself from http://www.afterlogic.com/updates/mailbee_net3.zip

You can use Intellisense to find out which classes and methods are available. Although the docs are not available yet, most classes, properties and methods have self-describing names.

To help you start with, I prepared a code snippet which extracts information from HTML table.

Code:

Element elem = new Element("<html><table>" +
  "<tr><td>FIRST_NAME</td>" +
  "<td>Bilbo</td></tr>" +
  "</table></html>");
ElementReadOnlyCollection tds =
  elem.GetAllElementsByName("td");
bool nextIsValue = false;
foreach (Element td in tds)
{
  if (nextIsValue)
  {
    Console.WriteLine("First name is [" +
      td.InnerHtml.Trim() + "]");
    nextIsValue = false;
  }
  if (td.InnerHtml.Trim() == "FIRST_NAME")
  {
    nextIsValue = true;
  }
}


You should also declare "using MailBee.Html;" in the beginning of C# source.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide