mitchenall.com - The Database & Web Enabling Company  
Services Products Resources Contacts
* Consultancy
* Training
* Bespoke Development
* Web Development and Hosting
* 4D Freeware
-> Articles & Tutorials
* External Links
* Site Index
* Recommended Reading
* @mitchenall.com
* Feedback

> Home > Resources > Articles & Tutorials > 4th Dimension

Resources4th Dimension

Formatting Emails in 4D

This tutorial shows a quick and dirty way of formatting emails on screen in a similar fashion to email clients such as MS Outlook Express (when I say quick, I mean to say that it's pretty fast, and dirty, because the code is written to be fast compiled and not necessarily easy to follow). The idea is to take an email stored in a text field/variable or a BLOB field/variable, find all the hyperlinks and quoted text, then display a coloured version of the email in a 4D Write area, in a way so that the hyperlinks are activated when the user double-clicks them.

The sample code has been lifted from Mail4th Express, the vapourware email client written with 4D 6.5. Although Mail4th Express has never been finished, these routines seem to work fine. The main bottleneck with this code is in the formatting the 4D Write document. It doesn't seem to matter whether this is done on or off screen, it's still slow in comparison to the parsing code. Emails that are bigger than about 64K take too long to format in our opinion. There is a faster way of creating 4D Write documents, but we will release something separately for that. Typically, on a Powerbook G3 500, parsing a 32K 4D NUG digest email and formatting in the 4D Write area takes approximately 1 second.

The examples have been designed to work with 4D v6.5 and 4D Write v6.5, although they should work with v6, the 4D Write code would definitely need looking into to ensure compatibility with earlier versions. They've also been tested with 4D/4D Write 6.7.

Important: Forget about using this code in an interpreted database unless you're only viewing extremely small emails. The routine used for parsing and formatting emails has been optimised for compiled running and will be extremely unpleasant for your users if you run this in interpreted mode.

Example database - Uncompiled 4D 6.5 Structure
Email_Formatter65.sit.bin MacBinary 80k
Email_Formatter65.sit.hqx BinHex 108k
Email_Formatter65.zip ZIP 124k

Next Page


 
Article Sections
-> Formatting Emails in 4D
An overview of the email formatting tutorial.
   
* What are we formatting?
What are we looking for in the email and what are we then going to do with it...
   
* Parsing Email in BLOBs
Here we'll look at the benefits of using a BLOB to parse this sort of data as quickly as possible as well as other types of data.
   
* Colouring Text and Hyperlinks
How to use 4D Write to display emails in their Outlook Express like glory.
   
* Alternatives
Some other ways in which emails can be parsed and formatted in 4D.
   
 
  For the XML source of this article, click here.
 
Other 4th Dimension Articles
Using Regular Expressions in 4D
This tutorial covers how to utlitise the power of regular expressions using 3rd party plug-ins in 4D.
 

> Home > Resources > Articles & Tutorials > 4th Dimension

 
4D Solutions Partner Logo

Last modified: 19 March 2001 by webmaster@mitchenall.com

[Home]
[Services]
[Products]
[Resources]
-> Articles & Tutorials
* External Links
* Site Index
* Recommended Reading
[Contacts]
 
Toolbar Component Valid HTML 4.01!
© mitchenall.com
1999-2002
Valid CSS!