How can I avoid random spaces in my HTML mail body when creating an email via Automation?
I am using: engine.SendEmail(emailOptions)
where emailOptions = new EmailOptions
The Message of the emailOptions is a string holding HML formatted data.
I've already tried adding a span style, but now I got an email where that exact tag got a random space...
Message = "<HTML><BODY><span style=\"white-space: nowrap;\">" +
"My custom mail body with hyperlinks and bullet lists.<br><br>" +
"</span></BODY></HTML>",
Due to these random spaces, my hyperlinks could fail and the mail content could contain HTML data making it less readable.
Hi Mieke,
When you add a mail action to your automation script, the mail content is inserted into a DataMiner HTML template (located in Skyline DataMiner\NotifyMail.html). In this template, the message is inserted into the 'contents' placeholder:
<html>
<head> ... </head>
<body> ...
<tr><td class="title">[title]</td></tr>
...
<tr><td class="contents">[contents]</td></tr>
...
</body>
</html>
The issue is that the mail content itself contains additional <html> and <body> tags, meaning a new <body> tag is opened inside an already existing <body> tag.
This results in invalid HTML. As a consequence, email clients may interpret the HTML inconsistently and automatically close/reopen tags internally. This can lead to unexpected formatting issues such as random spaces, extra empty lines, or inconsistent rendering.
The recommended solution is to only inject HTML fragments into the Message property without enclosing <html>, <head> or <body> tags.
Hope this helps you further!
I'll try this out. thank you for the clear explanation!