Hi Pete, thank you for participating,
Continuing testing, i have tryed both:
CommonFunctions.sendEmailTemplate - sends plain text
MVCFunctions.runner_mail - works - but heavy programming if sending newsletters with pictures ect.
Today i found out that runner_mail do the job but sendEmailTemlate sends only plain text.
Now i have this custom file named newstemplate.html
<html>
<head>
<title>Help Kids Code Project | How to Code an HTML Email</title>
</head>
<style type="text/css">
@media only screen and (max-width: 480px) {
/ mobile-specific CSS styles go here /
table[class=email], table[class=email-content] { clear: both; width: 320px !important; }}
</style>
<body>
<table width="99%" border="0" cellpadding="0" cellspacing="0">
<tr><td align="center" valign="top" bgcolor="#efefef">
Dear %cname%</td></tr>
<tr><td align="center" valign="top" bgcolor="#efefef">
This is testing</td></tr>
</table>
</body>
</html>
using this code in button (server event):
XVar dataarr = XVar.Array();
string email;
string strSQLExists = "select from customers where id=" + parameters["cusid"].ToString();
XVar rsExists = CommonFunctions.db_query(strSQLExists, null);
XVar data = CommonFunctions.db_fetch_array(rsExists);
dataarr.InitAndSetArrayItem(data["name"], "cname");
dataarr.InitAndSetArrayItem(data["created"], "membsince");
email = data["email"];
CommonFunctions.sendEmailTemplate(email, "newstemplate.html", dataarr);
sends plain text to reciever inbox!!
Using this code in button (server event):
XVar dataarr = XVar.Array();
string email;
string strSQLExists = "select from customers where id=" + parameters["cusid"].ToString();
XVar rsExists = CommonFunctions.db_query(strSQLExists, null);
XVar data = CommonFunctions.db_fetch_array(rsExists);
dataarr.InitAndSetArrayItem(data["name"], "cname");
dataarr.InitAndSetArrayItem(data["created"], "membsince");
email = data["email"];
string from = "crm@carmagic.dk";
string msg = "<html>";
msg = msg + "<head>";
msg = msg + "<title>Help Kids Code Project | How to Code an HTML Email</title>";
msg = msg + "</head>";
msg = msg + "<style type='text/css'>";
msg = msg + "@media only screen and (max-width: 480px) {";
msg = msg + " / mobile-specific CSS styles go here /";
msg = msg + "table[class=email], table[class=email-content] { clear: both; width: 320px !important; }";
msg = msg + "}";
msg = msg + "</style>";
msg = msg + "<body>";
msg = msg + "<table width='99%' border='0' cellpadding='0' cellspacing='0'>";
msg = msg + "<tr><td align='center' valign='top' bgcolor='#efefef'>";
msg = msg + "Dear " + data["name"].ToString() + "</td></tr>";
msg = msg + "<tr><td align='center' valign='top' bgcolor='#efefef'>";
msg = msg + "This is testing</td></tr>";
msg = msg + "</table>";
msg = msg + "</body>";
msg = msg + "</html>";
string subject = "This is testing MVCFunctions.runner_mail with html";
XVar mresult;
mresult = MVCFunctions.runner_mail(new XVar("to", email, "subject", subject, "htmlbody", msg, "from", from));
sends an email with html content to inbox :-)
Am i missing something in my code using sendEmailTemplate ??
Thank you in advance
Kind regards
Michael Fiil (Denmark)