PreviewMail
Back to ListDescription: Create HTML version of an Email text stored as markdown format.
FileMaker Prototype:
Set Variable [$res; ACF_Run("PreviewMail")]
Category: EMAIL
Dependencies
- emailServerPar: Create a JSON object with the server config for use in E-mail sending.
- FileGetContent: Read content of a file, return its content
- FilePutContent: Write some content to a file
NOTE: This function serves as a reference template. To use it effectively, you may need to adjust certain parts of the code, such as field names, database structures, and specific data lists to fit the requirements of your system. This customization allows the function to work seamlessly within your environment.
Function source:
function PreviewMail ()
string acc = Email_Messages::Email_Account;
string htmlfolder = Email_Accounts::HTML_Folder;
set_markdown_html_root ( htmlfolder );
string fileBase = htmlfolder+"/Temp_"+string(now(), "%Y%m%d_%H%I%S");
string mdFile = fileBase+".md";
string htmlFile = fileBase + ".html";
string mdContent = Email_Messages::MarkdownText;
JSON params = emailServerPar(acc); // the other function returns the server config...
// print string(params);
mdContent += params["server.Signature"];
string res = FilePutContent ( mdFile, mdContent);
string style = Email_Messages::Style + "," + Email_Messages::Codestyle;
res = markdown2html (mdFile, style , htmlFile);
string htmlContent = FileGetContent (htmlFile );
// Fix images that is too wide
htmlContent = regex_replace("(<img[^>]*)(>|\\/>)", htmlContent, "$1 style=\"max-width: 95%; max-height: 95%;\"$2");
// print htmlContent;
res = FilePutContent ( htmlFile, htmlContent);
return htmlFile;
end
