How to use the createsend.Campaign function in createsend

To help you get started, we’ve selected a few createsend examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github philippbosch / django-campaignmonitor / campaignmonitor / models / campaigns.py View on Github external
def create_draft(self, preview_recipients=[]):
        CreateSend.api_key = settings.API_KEY
        campaign = CSCampaign()
        attrs = dict(
            client_id=settings.CLIENT_ID,
            subject=self.subject,
            name=self.name,
            from_name=self.from_name,
            from_email=self.from_email,
            reply_to=self.from_email, # TODO
            html_url=self.html_url,
            text_url=self.text_url,
            list_ids=self.list_ids,
            segment_ids=self.segment_ids,
        )
        try:
            campaign_id = campaign.create(**attrs)
            self.cm_id = campaign_id
            self.status = self.STATUS_DRAFT
github philippbosch / django-campaignmonitor / campaignmonitor / models / campaigns.py View on Github external
def send(self, confirmation_email):
        if not self.cm_id:
            raise ValueError("No draft created yet")
        CreateSend.api_key = settings.API_KEY
        campaign = CSCampaign(self.cm_id)
        campaign.send(confirmation_email=confirmation_email)
        self.status = self.STATUS_SENT
        self.save()
github philippbosch / django-campaignmonitor / campaignmonitor / models / campaigns.py View on Github external
from_email=self.from_email,
            reply_to=self.from_email, # TODO
            html_url=self.html_url,
            text_url=self.text_url,
            list_ids=self.list_ids,
            segment_ids=self.segment_ids,
        )
        try:
            campaign_id = campaign.create(**attrs)
            self.cm_id = campaign_id
            self.status = self.STATUS_DRAFT
            self.save()
        except BadRequest, e:
            raise
        if len(preview_recipients):
            campaign = CSCampaign(campaign_id)
            campaign.send_preview(preview_recipients)