REBOL Programming/import-email

USAGE:Edit

IMPORT-EMAIL data /multiple parent 

DESCRIPTION:Edit

Constructs an email object from an email message.

IMPORT-EMAIL is a function value.

ARGUMENTS:Edit

  • data -- The email message (Type: string)

REFINEMENTS:Edit

  • /multiple -- Collect multiple fields in header
    • parent -- (Type: object)

SOURCE CODEEdit

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
]
Last modified on 30 October 2012, at 11:27