MAIL Convert to MIME
History
Release | Changes |
---|---|
17 R4 | Added |
17 R5 | Modified |
MAIL Convert to MIME( mail : Object { ; options : Object } ) : Text
Parameter | Type | Description | |
---|---|---|---|
Object | → | Email object | |
options | Object | → | Charset and encoding mail options |
Result | Text | ← | Email object converted to MIME |
Description
The MAIL Convert to MIME
command converts an email object into MIME text. This command is called internally by SMTP_transporter.send() to format the email object before sending it. It can be used to analyze the MIME format of the object.
In mail, pass the content and the structure details of the email to convert. This includes information such as the email addresses (sender and recipient(s)), the message itself, and the type of display for the message.
4D follows the JMAP specification to format the email object.
In options, you can set a specific charset and encoding configuration for the mail. The following properties are available:
Property | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
headerCharset | Text | Charset and encoding used for the following parts of the email: subject, attachment filenames, and email name attribute(s). Possible values:
| |||||||||||||||
bodyCharset | Text | Charset and encoding used for the html and text body contents of the email. Possible values: Same as for headerCharset (see above) |
If the options parameter is omitted, the mail mode UTF8 configuration is used for header and body parts.
Example
var $mail: Object
var $mime: Text
$mail:=New object
// Creation of a mail
$mail.from:="tsales@massmarket.com"
$mail.subject:="Terrific Sale! This week only!"
$mail.textBody:="Text format email"
$mail.htmlBody:="<html><body>HTML format email</body></html>"
$mail.to:=New collection
$mail.to.push(New object ("email";"noreply@4d.com"))
$mail.to.push(New object ("email";"test@4d.com"))
// transform the mail object in MIME
$mime:=MAIL Convert to MIME($mail)
// Contents of $mime:
// MIME-Version: 1.0
// Date: Thu, 11 Oct 2018 15:42:25 GMT
// Message-ID: <7CA5D25B2B5E0047A36F2E8CB30362E2>
// Sender: tsales@massmarket.com
// From: tsales@massmarket.com
// To: noreply@4d.com
// To: test@4d.com
// Content-Type: multipart/alternative; boundary="E0AE5773D5E95245BBBD80DD0687E218"
// Subject: Terrific Sale! This week only!
//
// --E0AE5773D5E95245BBBD80DD0687E218
// Content-Type: text/plain; charset="UTF-8"
// Content-Transfer-Encoding: quoted-printable
//
// Text format email
// --E0AE5773D5E95245BBBD80DD0687E218
// Content-Type: text/html; charset="UTF-8"
// Content-Transfer-Encoding: quoted-printable
//
// <html><body>HTML format email</body></html>
// --E0AE5773D5E95245BBBD80DD0687E218--
Properties
Command number | 1604 |
Thread safe | ✓ |