Rebol Programming/import-email

= USAGE: = IMPORT-EMAIL data /multiple parent

= DESCRIPTION: = Constructs an email object from an email message.

IMPORT-EMAIL is a function value. = ARGUMENTS: =
 * data -- The email message (Type: string)

= REFINEMENTS: =
 * /multiple -- Collect multiple fields in header
 * parent -- (Type: object)

= SOURCE CODE = import-email: func [ "Constructs an email object from an email message." data [string!] "The email message" /multiple "Collect multiple fields in header" parent [object!] /local content frm ][   data: parse-header either multiple [parent] [system/standard/email] content: data frm: func [val /local res] [ either block? val [ either empty? val [ copy "" ] [               res: copy first val foreach addlst next val [ insert insert tail res ", " addlst ]                res ]       ] [            val ]   ]     data/date: parse-header-date either block? data/date [first data/date] [data/date] data/from: parse-email-addrs frm data/from data/to: parse-email-addrs frm data/to all [multiple data/cc: parse-email-addrs frm data/cc] all [multiple data/bcc: parse-email-addrs frm data/bcc] data/reply-to: parse-email-addrs frm data/reply-to data/content: any [data/content tail content] data ]