Need

When configuring email notifications in SDP workflows, users often include multiline HTML content in the email body. If this HTML is not structured correctly in the YAML configuration, tools like VS Code may misinterpret each line as a separate YAML value, leading to validation issues or deployment failures. Additionally, unsupported HTML constructs (such as embedded <style> blocks) can cause workflow deployment to fail.

This article explains the correct and supported way to define multiline HTML email bodies in SDP workflows to ensure successful validation and deployment.


Summarized Solution

  • Do not define the email body using double quotes (").
  • Use the YAML block scalar syntax: body: |.
  • Properly indent all lines of the HTML content.
  • Do not include embedded <style> blocks in the HTML.
  • Apply all styling using inline CSS, which is supported and deployment-safe.

 

Detailed Solution

1. Avoid Using Double Quotes for Multiline HTML

Defining a multiline HTML body inside double quotes causes YAML parsers (and VS Code) to treat each new line as a separate value, which results in syntax errors.
Incorrect example:
body: "<html>
  <body>
    <p>Hello</p>
  </body>
</html>"
This approach leads to YAML parsing issues and should be avoided.


2. Use YAML Block Scalar Syntax (|)

To safely define multiline content, use the literal block scalar (|). This tells YAML to treat everything below it as plain text, preserving line breaks.
Correct example:
body: |
  <html>
    <body>
      <p>Hello</p>
    </body>
  </html>
Key points:
  • The | must be on the same line as body:.
  • All HTML lines must be consistently indented relative to body:


3. Ensure Proper Indentation

Indentation is critical in YAML. Every line of the HTML body must be indented by the same number of spaces.
Valid indentation:
body: |
    <html>
      <body>
        <p>This email was generated by an SDP workflow.</p>
      </body>
    </html>
Invalid indentation (will cause parsing errors):
body: |
  <html>
    <body>
  <p>Incorrect indentation</p>
    </body>
</html>

4. Do Not Use Embedded <style> Blocks

SDP workflow email configurations do not support embedded <style> blocks. Including them will cause the workflow deployment to fail.
Unsupported:
<style>
  p { color: red; }
</style>

5. Use Inline CSS Instead

All styling must be applied directly to HTML elements using inline styles, which are fully supported.
Supported and recommended:
body: |
  <html>
    <body>
      <p style="color: red; font-weight: bold;">
        Workflow execution completed successfully.
      </p>
    </body>
  </html>
Inline CSS ensures:
  • Successful deployment
  • Consistent rendering across email clients
  • Compatibility with SDP workflow constraints


6. Best Practices Summary

  • ✅ Always use body: | for multiline HTML
  • ✅ Maintain strict and consistent indentation
  • ✅ Use inline CSS only
  • ❌ Never use double quotes for multiline bodies
  • ❌ Never include <style> blocks
Following these practices will prevent YAML parsing issues, VS Code validation errors, and SDP workflow deployment failures when configuring HTML-based email notifications in Semarchy xDM.