mimeEncodeAsMIMEEmail
Type
command
Summary
Create data to be sent as an email
Syntax
mimeEncodeAsMIMEEmail <pBody>,<pFrom>,<pTo>,<pCc>,<pSubject>,<pAttachmentA>,<pHeadersA>
Description
Creates the data to be sent as an email via an SMTP server
Parameters
Name | Type | Description |
---|---|---|
pBody | The pre-encoded body of the email. See the mimeEncodeFieldAsMIMEMultipartDocument function for an easy way to generate the body from field content. | |
pFrom | From email address | |
pTo | Recipient email addresses with one per line | |
pCc | Copy to email addresses with one per line | |
pSubject | Email subject line | |
pAttachmentA | A numerically indexed (1..N) multi-dimensional array. Each element describes a different attachment. The elements of the array may contain the following keys.
| |
pHeadersA | An array containing key-value pairs where each key is the
name of a MIME header field name and the corresponding array element is the
encoded value that should be given to that header field. Header fields which are
given as parameters to |
Examples
local tBody
put mimeEncodeFieldAsMIMEMultipartDocument( \
the long id of field "email") \
into tBody
# Add a Reply-To address
local tHeadersA
put "sales-replies@livecode.com" into tHeadersA["Reply-To"]
# Add comments
put mimeEncodeForMIMEHeader(field "comments", "q") into tHeadersA["Comments"]
local tEmail
mimeEncodeAsMIMEEmail \
tBody, \
"sales@livecode.com", \
field "email", \
empty, \
"Purchase order", \
empty, \
tHeadersA
put it into tEmail
local tBytes, tSettings, tResponseHeaders
put "username" into tSettings["username"]
put "p@$$w0rd" into tSettings["password"]
local tResult
put tsNetSmtpSync( \
"smtps://mail.livecode.com:465", \
"sales@livecode.com", \
field "email", \
tEmail, \
tResponseHeaders, \
tBytes, \
tSettings) \
into tResult
if tResult begins with "tsneterr:" then
answer error "Error:" & word 2 to -1 of tResult
end if