...
Send Newsletter programmatically
If you also want to start sending the above Newsletter programmatically – i.e. by a Cronjob – you can create an EventFile and trigger sending with the following code snippet.
cmsbs-conf/cse/plugins/de.pinuts.tutorial/shared/SendOfferListNewsletter.es6
:
Codeblock | ||
---|---|---|
| ||
/// <reference path="../../../.vscode.js"/> const MAILING_TEMPLATE_NAME = 'offerlist-nl'; const CHANNEL_NAME = 'offerlist'; const NEWSLETTER_TAG = 'offerlist'; function createEventFile() { return `<event archive="true"> <destination> <channel>${Strings.encodeXml(CHANNEL_NAME)}</channel> </destination> <data> <message>${Strings.encodeXml(MAILING_TEMPLATE_NAME)}</message> <email archiveOutgoingEmails="false" obeyPreferHtml="false" sendBothParts="false" trackingMode="Off"></email> </data> <tag>${Strings.encodeXml(NEWSLETTER_TAG)}</tag> </event>`; } export function run() { UM.println('Preparing newsletter...'); const eventFile = createEventFile(); UM.newsletterArchive.send(eventFile); } de.pinuts.tutorial.sendNewsletter = run; |
Having done that you can create a CSE: Call Cronjob to periodically call de.pinuts.tutorial.sendNewsletter()
.