HTML Email Composer
MQL4's SendMail() sends plain text only - it has no HTML rendering at all, and a body containing raw "<table>" markup arrives at the inbox exactly as typed, tags and all. A library claiming to produce "HTML email" for the terminal without saying this plainly would be misleading. This one says it up front: the HTML it builds is a real, valid document meant to be saved to MQL4\Files and opened in a browser, or handed to something that genuinely accepts HTML (a webhook relay, a logging dashboard) - not a way to make the built-in mail sender render rich content, which nothing in MQL4 can do. HecHeading/HecParagraph/HecBadge/HecTable each build one escaped, styled HTML fragment; HecBuildDocument wraps a set of them into a complete document with a readable default style. HecStripTags() converts that same document into a genuinely readable plain-text version (paragraph and table-row boundaries become line breaks, tags are dropped, entities are decoded) - this is what HecSendAsPlainText() actually passes to SendMail(), so the mail that does go out reads sensibly rather than as raw markup. Notes and limitations - SendMail() itself never renders HTML - see the FULL DESCRIPTION above. This library's HTML output is for saving/viewing or for handing to a genuinely HTML-capable external channel, not for making the built-in mail sender rich. - SendMail() additionally requires Tools -> Options -> Email to be filled in and "Enable" ticked; it also has a documented per-run rate limit imposed by the terminal itself (roughly a handful of mails within a short window) that this header does not track or work around - that is a separate concern from ApiBudgetManager-style external rate limiting. - HecTable's row type caps at HEC_MAX_COLUMNS (16) cells per row - a wider table needs a higher constant recompiled into a private copy, this header does not resize the cap at runtime. - The escaper (HecEscapeHtml) targets the five characters that matter for safe HTML embedding plus newline-to-<br/>; it is not a general HTML sanitiser and should not be relied on for untrusted third-party input beyond a trading tool's own generated text. - FileOpen() is sandboxed to MQL4\Files (or MQL4\Files\ (or MQL5\Files\ on the native MQL5 build)Common with the commonFolder parameter) - it cannot write anywhere else on disk.
Script · MT4 · v1.0 · Free
About HTML Email Composer
HTML Email Composer is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 1 setting, such as Also send mail. MQL source code included.
Files in the download: HtmlEmailComposer.mqh, HtmlEmailComposer.txt, HtmlEmailComposerDemo.mq4.
Settings
| Setting | Default | What it does |
|---|---|---|
| Also send mail | false | also attempt a real SendMail() with the plain-text fallback |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Alerts · MT4 Script · MQL4 Source Code