This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.
Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.
Before posting questions here you might want to review the developer documentation.
Hi All,
From code, I would like to send a few html emails asynchronously, using SMTP.
The EmailMessageTask class could be used, except it's only allowing plain text emails. The code snippet below, taken from EmailMessagesTask.cs, shows that Email.Send() is not using html (second to last parameter is false).
public class EmailMessageTask { ... private void RunTask() { ... Email.Send( smtpSettings, emailFrom, emailFromAlias, emailReplyTo, emailTo, emailCc, emailBcc, subject, textBody, false, emailPriority); ... } ... }
We could expose UseHTML as a public property on EmailMessageTask and then pass that as the second to last parameter. For example:
public class EmailMessageTask { ... private bool useHTML = false; ... public bool UseHTML { get { return useHTML; } set { useHTML = value; } } ... private void RunTask() { ... Email.Send( smtpSettings, emailFrom, emailFromAlias, emailReplyTo, emailTo, emailCc, emailBcc, subject, textBody, useHTML, emailPriority); ... } ... }
Could we implement this, or is there an existing alternative in mojoPortal?
Kind regards,
Jonas
P.S
Another option would be to not use EmailMessageTask, instead have the Email class indirectly expose SmtpClient's SendAsync() method (see SmtpClient Class). This option would require more work.
I've added the UseHtml and HtmlBody properties on EmailMessageTask. This is in the source code repository now.
Best,
Joe
Great. Thanks Joe!