Loading...

All project content is available for reading, but you need to be a member of the project for Subversion checkout of source code, or to create/modify any information.
Login if you are a member. Apply here to request membership (open to all).

Newsletter Developers Guide

The Newsletter Page Type

In order for the Newsletter module to recognize your page type (model), it needs to inherit the BVNetwork.EPiSendMail.NewsletterBase class.

The base class has two optional properties: MailSender and MailSubject, used as from and subject for the email. You probably want to provide the MailSender property, or it will default to "noreply@" + SiteDefinition.Current.SiteUrl.Host. You can provide a better default address by adding an appSetting with the key Newsletter.DefaultFromAddress:

<appSettings>
  <add key="Newsletter.DefaultFromAddress" value="noreply@my.domain.com" />
</appSettings>

Alternatively, override the SetDefaultValues method on your newsletter model:

public override void SetDefaultValues(ContentType contentType)
{
    base.SetDefaultValues(contentType);
    MailSender = "noreply@my.domain.com";
}

Adding Custom Properties to Sender Engine

Implement the IPopulateCustomProperties interface on your newsletter model, and add the custom properties your sender engine understands.

Example: Adding campaign and tag to Mailgun

public class NewsletterPage : NewsletterBase, IPopulateCustomProperties
{
  ...

  [Display(
      Name = "Mailgun Campaign",
      Description = "The name of a campaign in Mailgun. Leave empty if you do not use Mailgun campaigns",
      GroupName = SystemTabNames.Content,
      Order = 30)]
  public virtual string MailgunCampaignName { get; set; }

  [Display(
      Name = "Mailgun Tag",
      Description = "The name of a tag in Mailgun. Leave empty if you do not use Mailgun tags. Note! Number of tags are limited to 200 in Mailgun.",
      GroupName = SystemTabNames.Content,
      Order = 40)]
  public virtual string MailgunTagName { get; set; }

  public void AddCustomProperties(Dictionary<string, object> properties)
  {
      if (string.IsNullOrEmpty(MailgunCampaignName) == false)
          properties.Add("o:campaign", MailgunCampaignName);

      if (string.IsNullOrEmpty(MailgunTagName) == false)
          properties.Add("o:tag", MailgunTagName);
  }
}