4D v18

MAIL Convert from MIME

Home

 
4D v18
MAIL Convert from MIME

MAIL Convert from MIME 


 

MAIL Convert from MIME ( mime ) -> Function result 
Parameter Type   Description
mime  BLOB, Text in Email in MIME
Function result  Object in Email object

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

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

Email object. For a detailed description of this object, please refer to the transporter.send( ) method.

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

 C_BLOB($mime)
 C_OBJECT($mail;$server;$transporter;$status)
 
 $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)

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

 C_TEXT($mime)
 C_OBJECT($email;$server;$transporter;$status)
 
  // 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)



See also 

attachment.getContent( )
SMTP_transporter.send( )

 
PROPERTIES 

Product: 4D
Theme: Mail
Number: 1681

 
HISTORY 

New
Created: 4D v18

 
ARTICLE USAGE

4D Language Reference ( 4D v18)