KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Sending 4D Write Pro HTML emails may differ in appearance based on email application and OS
PRODUCT: 4D | VERSION: 17 R | PLATFORM: Mac & Win
Published On: November 15, 2019

When sending 4D Write Pro emails as HTML using the new Transporter commands, be aware that some email clients may restrict certain styles, fonts, or formats. In this example, a 4D Write Pro is sent to the same receipient , same email application, but viewed on different operating systems (Mac and Win). The example code is shown below:

// Method: transporterSendWP
// Description:
// Example method to send a 4D Write Pro document as HTML to email
//
// ----------------------------------------------------

C_TEXT($path_t;$wp_t)
C_OBJECT($server_o;$email_o;$transporter_o;$status_o;$wp_o)

$server_o:=New object
$server_o.host:="exchange.4d.com"
$server_o.port:=587
$server_o.user:="some_email@4d.com"
$server_o.password:="some_password"

$transporter_o:=SMTP New transporter($server_o)

$path_t:=Get 4D folder(Database folder)+"test.4wp"
$wp_o:=WP Import document($path_t)
WP EXPORT VARIABLE($wp_o;$wp_t;wk web page html 4D;wk normal)

$email_o:=New object
$email_o.subject:="Transporter Test Email"
$email_o.from:="fromEmail@4d.com"
$email_o.to:="toEmail@4d.com"
$email_o.textBody:="Hello World"
$email_o.htmlBody:=$wp_t

$status_o:=$transporter_o.send($email_o)
If (Not($status_o.success))
   ALERT("An error occurred sending the mail: "+$status_o.message)
Else
   ALERT("Email sent")
End if


MacOS Outlook:


Windows Outlook: