SendMail.SetHTMLText
--------------------

Sets the HTML text of the new email.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [SendMail](component_SendMail.md) | [4.3](newinversion43.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "SendMail.SetHTMLText"; EmailID; Text ) 

**MBS**( **"SendMail.SetHTMLText";** /\* Sets the HTML text of the new email. \*/  
**$EmailID**; /\* The email reference number obtained using [SendMail.CreateEmail](SendMailCreateEmail.md) function. \*/   
**$Text**) /\* The HTML text for the email. Will be encoded by the plugin to quoted printable UTF-8.e.g. Email::HTMLText \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| EmailID | The email reference number obtained using [SendMail.CreateEmail](SendMailCreateEmail.md) function. | $EmailID |
| Text | The HTML text for the email. Will be encoded by the plugin to quoted printable UTF-8. | Email::HTMLText |

### Result

Returns OK or error.

### Description

Sets the HTML text of the new email.  
See also [SendMail.SetPlainText](SendMailSetPlainText.md) and [SendMail.SetRichText](SendMailSetRichText.md).  
If you need to encode text yourself to html, you can use the [Text.EncodeToHTML](TextEncodeToHTML.md) function.  
You can read html content from file using the [Text.ReplaceNewLine](TextReplaceNewLine.md) function.  
  
You can use [Text.MergeFields](TextMergeFields.md) to replace placeholders with values from variables, fields and expressions.  
  
Reference inline images with "cid:" prefix in the html text and add them with [SendMail.AddAttachmentContainer](SendMailAddAttachmentContainer.md) or [SendMail.AddAttachmentFile](SendMailAddAttachmentFile.md) function.  
### Examples

Create email and set content:

 Set Variable \[$EmailID ; Value:MBS ("[SendMail.CreateEmail](SendMailCreateEmail.md)")\]  
Set Variable \[$r ; Value:MBS ("SendMail.SetHTMLText"; $EmailID ; $html )\]  
Sets the text as plain text and as html:

 Set Variable \[ $r ; Value: MBS ("SendMail.SetHTMLText"; $EmailID ; "&lt;html&gt;&lt;body&gt;" &amp; GetAsCSS(EMail::PlainText ) &amp; "&lt;/body&gt;&lt;/html&gt;") \]   
Set Variable \[ $r ; Value: MBS ("[SendMail.SetPlainText](SendMailSetPlainText.md)"; $EmailID ; EMail::PlainText ) \]  
Add inline graphics with placeholder in HTML:

 Set Variable \[ $EmailID ; Value: MBS ("[SendMail.CreateEmail](SendMailCreateEmail.md)") \]   
\# prepare HTML from field in FileMaker   
Set Variable \[ $html ; Value: "&lt;html&gt;&lt;body&gt;" &amp; GetAsCSS(EMail::PlainText ) &amp; "&lt;/body&gt;&lt;/html&gt;" \]   
\# Replace $$img $$ in text with image.   
Set Variable \[ $html ; Value: Substitute($html ; "$$img $$"; "&lt;img src=\\"cid:image1.png\\"&gt;") \]   
Set Variable \[ $r ; Value: MBS ("SendMail.SetHTMLText"; $EmailID ; $html ) \]   
\# now add a container   
Set Variable \[ $r ; Value: MBS ("[SendMail.AddAttachmentContainer](SendMailAddAttachmentContainer.md)"; $EmailID ; EMail::ImageContainer ; EMail::ImageName ; "image/png"; "image1.png") \]  
Set html with converting text field:

 MBS ( "SendMail.SetHTMLText"; $EmailID ; MBS ( "[Text.TextToHTML](TextTextToHTML.md)"; MyTable::MyTextField ) )  
### See also

- [SendMail.AddAttachmentContainer](SendMailAddAttachmentContainer.md)
- [SendMail.AddAttachmentFile](SendMailAddAttachmentFile.md)
- [SendMail.CreateEmail](SendMailCreateEmail.md)
- [SendMail.GetHTMLText](SendMailGetHTMLText.md)
- [SendMail.SetPlainText](SendMailSetPlainText.md)
- [SendMail.SetRichText](SendMailSetRichText.md)
- [Text.EncodeToHTML](TextEncodeToHTML.md)
- [Text.MergeFields](TextMergeFields.md)
- [Text.ReplaceNewLine](TextReplaceNewLine.md)
- [Text.TextToHTML](TextTextToHTML.md)

### Example Databases

- [CURL/Email/Batch Emailer](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/Batch%20Emailer.shtml#1ScriptAnchor_)
- [CURL/Email/Build and send Email](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/Build%20and%20send%20Email.shtml#1ScriptAnchor_)
- [CURL/Email/Build and send HTML Email with inline graphics](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/Build%20and%20send%20HTML%20Email%20with%20inline%20graphics.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS Plugin Advent calendar: 21 - SendMail](https://www.mbsplugins.de/archive/2023-12-21/MBS_Plugin_Advent_calendar_21_/monkeybreadsoftware_blog_filemaker)
- [Sending email with a huge custom function](https://www.mbsplugins.de/archive/2021-06-26/Sending_email_with_a_huge_cust/monkeybreadsoftware_blog_filemaker)
- [Use Inline Graphics in Emails](https://www.mbsplugins.de/archive/2021-02-11/Use_Inline_Graphics_in_Emails/monkeybreadsoftware_blog_filemaker)
- [Email Script for FileMaker](https://www.mbsplugins.de/archive/2018-10-10/Email_Script_for_FileMaker/monkeybreadsoftware_blog_filemaker)
- [Sending emails in FileMaker with MBS Plugin](https://www.mbsplugins.de/archive/2016-10-03/Sending_emails_in_FileMaker_wi/monkeybreadsoftware_blog_filemaker)
- [Sending Email with FileMaker via MBS Plugin](https://www.mbsplugins.de/archive/2014-09-29/Sending_Email_with_FileMaker_v/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 6/2024, Seite 38](https://filemaker-magazin.de/neuigkeit/4277-Appetithappen-FMM_202406)

This function checks for a license.

Created 3th September 2014 , last changed 23th July 2024

  
[SendMail.SetFrom](SendMailSetFrom.md) - [SendMail.SetInReplyTo](SendMailSetInReplyTo.md)

[HTML Version](SendMailSetHTMLText.shtml)