Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 14 in printed book and digital formats -- plus a one-year subscription so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 2.2

COLUMN

E-mail and Encodings

Issue: 2.2 (October/November 2003)
Author: Didier Barbas
Article Description: No description available.
Article Length (in bytes): 6,815
Starting Page Number: 46
Article Number: 2222
Resource File(s):

Download Icon 2222.zip Updated: 2013-03-11 19:07:57

Related Link(s): None

Excerpt of article text...

One of the interesting features of RB 5 is the set of new sockets, which enables easier management of TCP communication. Along with these sockets thereappeared an EmailMessage class, which, used in conjunction with POP3(Secure)Socket and SMTP(Secure)Socket, gives the RB user an easy way to build an e-mail program. However, dealing correctly with e-mail sources is complex, and has many traps. As of today, the EmailMessage class breaks on several occasions, one of which is when receiving e-mail from the Apple Developer Connection. Also, e-mail messages with several character sets are really not easy to manage, and the EmailMessage doesn't provide you with a way to deal with that. This is why I decided to build a class that would manipulate e-mail sources in a more convenient and accurate manner, enabling the user to pass the raw source to the class and get back a complete set of properly formatted elements: Properly encoded subject line (you can have an unlimited number of charsets in this single line...), properly encoded text elements, attachments, pictures (either as files or as RB picture objects, full-sized or resized), and so forth.

Determining the requirements

The first requirement is actually to determine whether the source passed is a multipart message or not. If it is not, the class can still handle it, but in a separate routine.

Then we have to decode the title, formally the Subject header, and store it, properly encoded, in a property. Then we have to extract the parts of the message, whether there are several or just one. For each part, we get the headers (encoding -- Base64, quoted-printable -- charset, Content-type/disposition, filename), and store these headers and the sub-source into arrays for faster retrieval. Also, we should set BodyPlain and BodyHTML on the fly, when encountering adequate text elements.

...End of Excerpt. Please purchase the magazine to read the full article.