Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

...

Codeblock
languagebash
umkickstarter -n de.pinuts.tutorial
cd umkickstarter
# Copy your partner license file to env/devel/cmsbs-conf/cmsbs.license
gradle setup run

Create Newsletter Template

...

Implement a new RenderEntryCall method that will be called by the withcse directive from within the Newsletter Template just created.

This method should return true to indicate that the string in this.value should be rendered into the newsletter body.

cmsbs-conf/cse/plugins/de.pinuts.tutorial/callback/RenderEntryCallback.es6:

...

To generate some random content we use the DemoData plugin. Include the dependency into your build.gradle file and run gradle setup run again once more:

Codeblock
languagegroovy
...

dependencies {
    runtime('de.pinuts.cmsbs:UM:7.34.1')
    runtime('de.pinuts.cmsbs:TestDriver2:2.0.6')
    runtime('de.pinuts.cmsbs:DemoData:1.0.4')
}

.....

Send Newsletter manually

Now manually create a List named offerlist and some Entries with email addresses that are subscribed to that list.

Send a Newsletter manually based on the template created earlier.

Goto Tools / Mail Log to verify that emails have been sent and actually do contain the dynamically generated content.

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
languagejs
/// <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;

build.gradle:

...

languagegroovy

...

Having done that you can create a CSE: Call Cronjob to periodically call de.pinuts.

...

tutorial.sendNewsletter().