This project is read-only.

Preparing Resource Files

All text of messages is stored outside of your VB.NET/C# code in resource (.resx) files. This means that text of messages can be changed without changing your code.

Creating resource file

In case of web site projects the resource file must be created in the ~/App_GlobalResources/ folder. In other project types the location generally does not matter, but usually folder called Resources is used.

The resource name is set in Configuration, in examples is used file named MailerTemplates.resx.

Creating keys in resource file

The resource file contains 'Keys' with values used by the toolkit.

First there are keys determining general formatting of subject and body of all messages being sent. For example you may want all subjects of messages prefixed by name of your site and common footer for all messages.

Name of these keys is configurable, but defaults to _SubjectFormat and _BodyFormat (the underscore is important and ensures that these keys are placed on top of all keys in default view). These keys are expected to contain the {0} string, which marks the place, where the main content is put.

Typical setup might be for _SubjectFormat:
[] {0}

and for _BodyFormat:

This message was sent from unattended mailbox - please do not reply.
You may contact us at

Creating template keys

Each mail template consists of two parts and two keys. One for message subject and one for message body. The suffixes for these keys are also configurable and default to Subject and Body. Therefore template named MyTemplate would have two keys, one named MyTemplateSubject and one MyTemplateBody.

The keys may contain any number of placeholders in the {number} syntax used my the string.Format() method. For example you may create the following template to notify user that his order was shipped:

The OrderShippedSubject key:
Your order #{0} was just shipped

and the OrderShippedBody key:

your order #{0} was shipped today ({1:d}) using {2}.

The tracking number of the parcel is {3}.


We can use the following C# code to send the templated message specified above:
    "", // recipient e-mail address
    "OrderShipped",         // template name
    12345,                  // {0} - order number
    DateTime.Now,           // {1} - current time
    "DHL",                  // {2} - shipping company name
    "1234ABCDEF");          // {3} - tracking number

The received message would have subject [] Your order #12345 was just shipped and contents

your order #12345 was shipped today (6/6/2010) using DHL.

The tracking number of the parcel is 1234ABCDEF.

This message was sent from unattended mailbox - please do not reply.
You may contact us at


You may create localized versions of the messages by copying the resource file and adding the ISO language code fo the extension. For example, if your native resource is MailerTemplate.resx, the localized file names would be:
  • MailerTemplate.cs.resx for Czech
  • for German (without country specified)
  • for German (Germany)
  • for German (Austria)

See Usage from code for instructions how to send message in specific language.

Last edited Jun 3, 2013 at 2:51 PM by altair, version 2


No comments yet.