Skip to main content
Version: 20 R7 BETA

MAIL Convert from MIME

History
ReleaseChanges
18Added

MAIL Convert from MIME( mime : Blob ) : Object
MAIL Convert from MIME( mime : Text ) : Object

ParameterTypeDescription
mimeBlob, TextEmail in MIME
ResultObjectEmail object

Description

The MAIL Convert from MIME command converts a MIME document into a valid email object.

4D follows the JMAP specification to format the returned email object.

Pass in mime a valid MIME document to convert. It can be provided by any mail server or application. You can pass a BLOB or a text mime parameter. If the MIME comes from a file, it is recommended to use a BLOB parameter to avoid issues related to charset and line break conversions.

Returned object

Email object.

Example 1

You want to load a mail template saved as MIME in a text document and send an email:

var $mime: Blob
var $mail;$server;$transporter;$status: Object

$mime:=File("/PACKAGE/Mails/templateMail.txt").getContent())

$mail:=MAIL Convert from MIME($mime)
$mail.to:="smith@mail.com"
$mail.subject:="Hello world"

$server:=New object
$server.host:="smtp.gmail.com"
$server.port:=465
$server.user:="test@gmail.com"
$server.password:="XXXX"

$transporter:=SMTP New transporter($server)
$status:=$transporter.send($mail)

Example 2

In this example, you send directly a 4D Write Pro document containing pictures:

var $mime: Blob
var $email;$server;$transporter;$status: Object

// Mime export of the 4D Write Pro document
WP EXPORT VARIABLE(WParea;$mime;wk mime html)

// convert 4D Write Pro Mime variable in mail object
$email:=MAIL Convert from MIME($mime)

// Fill your mail object headers
$email.subject:="4D Write Pro HTML body"
$email.from:="YourEmail@gmail.com"
$email.to:="RecipientEmail@mail.com"

$server:=New object
$server.host:="smtp.gmail.com"
$server.port:=465
$server.user:="YourEmail@gmail.com"
$server.password:="XXXX"

$transporter:=SMTP New transporter($server)
$status:=$transporter.send($email)

| mime | BLOB, Text | → | Email in MIME | | Function result | Object | ← | Email object |