I have been interfacing into MS-Exchange using UniVerse sockets and IMAP.
I have been able to obtain access to specified user mailboxes, storing the status of each in a file every 10 minutes. The results, after some weeks, are now starting to show patterns. Which days are the busiest for receiving emails and how the users respond and answer them.
I next step was to download the actual email and archive the contents. Then I can cross reference the email addresses with the customer database, enabling a log or notational history of correspondence.
But I have come across an interesting problem. The problem of lists and the decoding of such. The IMAP specification uses ‘(‘ to delimit lists of items .e.g a list of emails is wrapped in (). A list within a list is ((..)) etc. And there is also string delimiting using “..”. The actual fields are space delimited, just to make it all interesting.
This problem also crops up with CSV (Comma Separated Value) formatted data. Comma’s are used to separate fields. If a field is a text field and it has a comma, the complete field is delimited in double quotes.
So, it is not as simple as replacing all comma’s with a @FM
EQUATE COMMA TO "," TEXT = CHANGE(TEXT, COMMA, @FM)
as the comma within a text field all be replaced with a field marker and the text field will end up split.
So, I used a turing engine to step through each character within the text string, comparing with a list of delimiters and setting/unsetting flags (state register) to break the string into fields, value and subvalues. All good stuff…
Except I keep thinking that there has to be a better way. It is similar to parsing XML, so maybe I can convert to XML and then use U2 XML to parse and convert to a record?
I need to think on this one…