Welcome to MSDN Blogs Sign in | Join | Help

Cristiano WebLog

Microsoft Infrastructure & Development Tips and Tricks
Playing with Direct Mailer!

Hey! I’m back with more Commerce Server 2007.

Now the subject is Direct Mailing. Commerce Server 2007 is great on direct mailing. This feature allows the use of a ASPX template to generate e-mail marketing campaigns with same personalization resources that we have with normal commerce server websites.

Before let’s check some of the direct mailing concepts:

  • Direct mail is a marketing campaign item (as an advertisement or discount) that you can target toward specific users by using mailing lists.
  • You can create new direct mail items, personalize messages, add attachments to direct mail messages, and modify properties of direct mails. Also you can choose the e-mail format (MHTML, HTML, TEXT only, etc)
  • For sure, you can also test direct mails before sending them to the real website users.

The necessary steps to create e-mail marketing campaigns are pretty straightforward:

  • Create an ASP .Net template page containing the personalized discount. This is a normal ASP .Net page with custom code based on the Commerce Server 2007 server API used to generate the HTML content that will be sent on the e-mails.
  • The second step is generating a mailing list (for example, a list of top users, a list of female users living in São Paulo, etc).
  • Now you can create a direct mail item targeting the mailing list generated.
  • Enter the name of the template page containing personalized content.
  • If needed, you can also add an attachment to the direct mail campaign.
  • Schedule the start times and end times for the direct mail item, and specify how often the direct mail job is to be sent.
  • Test the direct mail you sent against a test list, and view your personalization pages.
  • If the e-mail was sent correctly to the test list, approve it and let the server work running your marketing campaign.
  • Tell your customer to start counting dollars. :)

Now I know you are thinking something similar to: “What did he say with straightforward?” “I don’t know how to generate the template page and I don’t have a minimal idea on how to setup the direct mailing environment”.

Ok… sorry…

You should start with a sample ASP .Net template for direct mail personalization available on the /Microsoft Commerce Server 2007/SDK/Marketing folder of your Commerce Server installation.

<%@ Page language="c#" Inherits="DirectMailPage.DirectMailPage" CodeFile="DirectMailPage.aspx.cs" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<html>
  <body>
   Dear <%=GetName()%>,<br />
   <br />
   Thank you for signing up at our site on <%=GetRegisteredDate()%> .
   <br />
   As per your request, we will use the email address
mailto:<%=GetEmailAddress()%> for future communications.
   <br />
   We look forward to your business.
  </body>
</html>

As you can see, that page is very simple and the personalization code is implemented with two code behind (or beside? :)) functions. The GetName function returns the name of the user and the GetEmailAddress gets the smtp address filled on the user profile.

For each user on the generated list of the direct mailing campaign item, the Commerce Server 2007 direct mail engine will authenticate and run the template page in behalf of the user. The resulted HTML will be included on the e-mail body and sent to the user using his e-mail address.

The sample page is a very simple page. As the Commerce Server 2007 authenticates the user and run the ASP .Net template using his context, any feature of the commerce website can be used on the direct mail campaigns. This includes advertisements, discounts and even more sophisticated implementations.

But how commerce server direct mailer module authenticates the user? The direct mailing system generates a commerce server AuthTicket as a specific user. So, the value of UserId is encrypted and set as the AuthTicket value, the ticker is added as a cookie to the HTTP Request that direct mailer issues to the URL of the template page.

Therefore, the Commerce Server 2007 website that hosts the template page should have the profiles and CommerceDirectMailerAuthenticationModule sections of the web.config configured correctly in order to allow the decryption of the AuthTicket.

Below is a working sample of the web.config sections:

<profiles>
 <userProfile profileDefinition="UserObject" userIdProperty="GeneralInfo.user_id" organizationIdProperty="AccountInfo.org_id" catalogSetIdProperty="AccountInfo.user_catalog_set" userIdSource="ASP.NET" userIdKey="GeneralInfo.email_address" userIdTarget="GeneralInfo.user_id"/>
</profiles>

<httpModules>
...
<add name="CommerceDirectMailerAuthenticationModule" type="Microsoft.CommerceServer.Runtime.CommerceDirectMailerAuthenticationModule, Microsoft.CommerceServer.Runtime, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
...
</httpModules>

Finally a small tip. When I first ran a direct mailing campaign on my test system, I used a static test list generated manually (including the user e-mail addresses on the Add User to List windows form).

The manual generation of the list creates a file like the following one:

user1@test.local,,,,,
user2@test.local,,,,,

When you run the test execution of the direct mailing campaign, the Commerce Server is unable to create the correct AuthTicket because the list doesn’t have the user-id inside it. When you generate a dynamic list and use it on the test, the ticket is correctly created and the test works.

After checking the text file (exported from a dynamic generated list) you can see that the used ID is correctly filled.

user1@test.local,{7059a3be-b7c5-403a-b8c0-7e66cb43e76d},,,,
user2@test.local,{3a48fb87-2cfe-4567-9739-df521398021f},,,,

So, if you want to use static lists, remember to fill the userID and import the file before run the campaign.

[]'s.

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Posted: Thursday, September 14, 2006 6:51 PM by crisag
Filed under:

Comments

Vandana said:

Nice Article.It will help me

# June 26, 2007 8:39 AM

Eric_Halsey said:

Great article.  Thanks!  I had to make one change.  The GetProfileProperty function didn't return the date correctly.

private string GetProfileProperty(string propertyName)

{

   if (this.UserProfile != null)

   {

       ProfileProperty property = UserProfile[propertyName];

       if (property != null)

       {

           string _retval = property.Value.ToString();

           return _retval;

       }

   }

   return string.Empty;

}

# September 23, 2008 11:59 PM
Anonymous comments are disabled
Page view tracker