4D v18

MAIL Convert to MIME

Home

 
4D v18
MAIL Convert to MIME

MAIL Convert to MIME 


 

MAIL Convert to MIME ( mail {; options} ) -> Function result 
Parameter Type   Description
mail  Object in Email object
options  Object in Charset and encoding mail options
Function result  Text in Email object converted to MIME

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.
For more information on the eMail object, please refer to the SMTP_transporter.send( ) method description.

Note: 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:

PropertyTypeDescription
headerCharsetTextCharset and encoding used for the following parts of the email: subject, attachment filenames, and email name attribute(s). Possible values:
Constant Value Comment
mail mode ISO2022JP US-ASCII_ISO-2022-JP_UTF8_QP
  • headerCharset: US-ASCII if possible, Japanese (ISO-2022-JP) & Quoted-printable if possible, otherwise UTF-8 & Quoted-printable
  • bodyCharset: US-ASCII if possible, Japanese (ISO-2022-JP) & 7-bit if possible, otherwise UTF-8 & Quoted-printable
mail mode ISO88591 ISO-8859-1
  • headerCharset: ISO-8859-1 & Quoted-printable
  • bodyCharset: ISO-8859-1 & 8-bit
mail mode UTF8 US-ASCII_UTF8_QP

headerCharset & bodyCharset: US-ASCII if possible, otherwise UTF-8 & Quoted-printable (default value)

bodyCharsetTextCharset 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  

 C_OBJECT($mail)
 C_TEXT($mime)
 $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--



See also 

SMTP New transporter
SMTP_transporter.send( )

 
PROPERTIES 

Product: 4D
Theme: Mail
Number: 1604

This command can be run in preemptive processes

 
HISTORY 

Created: 4D v17 R4
Modified: 4D v17 R5

 
ARTICLE USAGE

4D Language Reference ( 4D v18)