Developing Direct Mail Content
The Direct Mail module of Commerce Server 2000 allows you to send targeted email messages by using customer information and custom Active Server Pages (ASP). Direct Mailer acts similarly to a Web browser by gathering the UserID for the customer from a cookie, using the profile service to obtain the user profile, and finally personalize the page. But Direct Mailer renders the content as an E-mail message instead of a Web page.
The following example, ServiceReminder.asp, can be used to create Direct Mail content. When implemented, this ASP file will send out personalized E-mail messages reminding each of your customers to come to your Web site to view new products. The ASP file also includes an opt-out link if they would like to be removed from your mailing list.
In this example, the UserID is retrieved from the AuthManager object, and the UserObject profile is retrieved from the profile service. For personalization to work correctly with this example, the mailing list must include both an E-mail address and a UserID for all entries. If the mail list has no UserID, the mail will not be sent. If the personalization flag is not turned on, the mail will not be sent. For more information about creating a mailing list, see Creating a Mailing List.
<%@ Language=VBScript %>
<%
Option Explicit
Response.AddHeader "pragma", "no-cache"
Response.Expires = 0
%>
<html>
<head>
</head>
<div class=Section1>
<%
Dim objAuthManager
Dim objUPM
Dim objProfile
Dim strUserID
Dim sCookieData
On Error goto 0
' Get User ID from AuthManager object.
SET objAuthManager = Server.CreateObject("Commerce.AuthManager")
objAuthManager.Initialize(Application("MSCSCommerceSiteName"))
if( Err.number <> 0 ) Then
Response.Write "<P>AuthManager Failed to initialize</P>"
End If
If Request.Cookies("CampaignItemID") <> "" Then' Part of a Campaign
strUserID = objAuthManager.GetUserID(1)
if( Err.number <> 0 ) Then
Response.Write "<P>Failed to get UserID</P>"
End If
Else' Not part of a Campaign
' The fix for being able to send personalized direct mail outside ' of a campaign is to toggle the comments on the two lines below.
' But please ensure that the web server that generates the
' personalized content is placed behind a firewall (since the user
' guid that is passed in not encrypted in this case).
Err.Raise &H80004005, , "Error: CampaignItemID was not specified"
' strUserID = Request.Cookies("MSCSProfile")
End If
' Get UserObject from profile Service
Set objUPM = Application("MSCSProfileService")
If (Err.Number <> 0) Then
Response.Write "<P>Failed to create Commerce.ProfileService</P>"
End If
Set objProfile = objUPM.GetProfileByKey("User_ID", strUserID, "UserObject")
If (Err.Number <> 0) Then
strErrMsg = "<P>User profile not found: " & strUserID & "</P>"
Response.Write strErrMsg
End If
%>
<table border=1 cellspacing=0 cellpadding=0 bgcolor="#ffff99" style='background:
#FFFF99;border-collapse:collapse;border:none;mso-border-alt:solid windowtext .5pt;
mso-padding-alt:0in 5.4pt 0in 5.4pt'>
<tr>
<td width=655 valign=top style='width:490.9pt;border:solid windowtext .5pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoPlainText><span style='font-family:Tahoma;
mso-fareast-font-family: "MS Mincho"'>
From: E-mail Notifier<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-family:Tahoma;
mso-fareast-font-family:
"MS Mincho"'>Sent: <% = Date() %><o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-family:Tahoma;
mso-fareast-font-family:
"MS Mincho"'>To: <% = objProfile.GeneralInfo.First_Name %><o:p> </o:p><% = objProfile.GeneralInfo.Last_Name %><o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-family:Tahoma;
mso-fareast-font-family:
"MS Mincho"'>Subject: </span><b><span style='font-size:12.0pt;
mso-bidi-font-size: 10.0pt;font-family:Tahoma;
mso-fareast-font-family:"MS Mincho";color:blue'>
New product notice</span></b><span style='mso-fareast-font-family:
"MS Mincho"'><o:p></o:p></span></p>
</td>
</tr>
</table>
<p class=MsoPlainText><b><span style='font-size:12.0pt;
mso-bidi-font-size:10.0pt; mso-fareast-font-family:
"MS Mincho";color:blue'><![if
!supportEmptyParas]> <![endif]><o:p></o:p></span></b></p>
<p class=MsoPlainText><span style='font-family:Tahoma;
mso-fareast-font-family:
"MS Mincho"'>Dear <% = objProfile.GeneralInfo.First_Name
%>,<o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-family:Tahoma;
mso-fareast-font-family:
"MS Mincho"'><span style="mso-spacerun: yes">
</span><o:p></o:p></span></p>
<p class=MsoPlainText><span style='font-family:Tahoma;
mso-fareast-font-family: "MS Mincho"'>
<span style="mso-spacerun: yes"> </span>We have added some exciting
new products to our Web site. <o:p></o:p>
<A HREF="<% =objAuthManager.GetUrl("default.asp", False, False)
%>">Come see us today!</A>.<o:p></o:p></span></p>
<p class=MsoNormal style='mso-layout-grid-align:none;
text-autospace:none'><span style='font-size:10.0pt;
font-family:Arial;color:navy'>
<![if !supportEmptyParas]> <![endif]><o:p></o:p></span></p>
<p class=MsoNormal style='mso-layout-grid-align:none;
text-autospace:none'><span style='font-size:10.0pt;
font-family:Arial;color:navy'><span style='mso-tab-count:
1'> </span><o:p></o:p></span></p>
<p class=MsoPlainText><span style='mso-fareast-font-family:
"MS Mincho"'>__________________________________________
<o:p></o:p></span></p>
<p class=MsoPlainText><i><span style='font-size:8.0pt;
mso-bidi-font-size:10.0pt; font-family:Verdana;
mso-fareast-font-family:"MS Mincho"'>TO UNSUBSCRIBE: You
have received this e-mail notifier as a result of your personal
registration.<BR>To unsubscribe from this e-mail notifier, click
the link below. <o:p></o:p></span></i></p>
<p class=MsoPlainText><i><span style='font-size:8.0pt;
mso-bidi-font-size:10.0pt;
font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>
<A HREF="<% On Error Goto 0
Response.Write objAuthManager.GetUrl
("opt-out.asp", False, False, _
Array("rcp_email", "campitem_id", "campitem_name"), _
Array(CStr(objProfile.GeneralInfo.email_address),
CStr(Request.Cookies("CampaignItemId")),
CStr(Request.Cookies("CampaignItemName"))) _
) %>">Click here to opt-out of future
mailings.</A><o:p></o:p></span></i></p>
</div>
</body>
</html>
To use this example you must first create a campaign. For more information, see Creating a Direct Mail Campaign.
On the Campaign Manager <Customer> <Campaign> New (direct mail) screen, in the Direct Mail Properties section, do the following.
Use this | To do this |
Direct mail name | Type a name for the direct mail job. |
Message from e-mail address | Type the address that the direct mail is being sent from. |
Reply to e-mail address | Type the address to which the recipient is to reply if different from the default address.
This box defaults to the address the direct mail is being sent from. |
Message subject | Type the subject text for this direct mail job. |
File path or URL containing message body | Type the URL that you are using to display the direct mail message. For example, http://<host_name>/<site_name>/ServiceReminder.asp. |
Attachment | Leave blank. |
Mailing list | Select the mailing list that this direct mail campaign will use from the drop-down list. This mailing list must have E-mail addresses and valid UserIDs, other columns are optional. |
Personalize direct mail per user | Select the checkbox. |
Mail format | Select MHTML. |
Comments (not included in message) | Type any required comments that are pertinent to this direct mail job. |
If you are sending the ServiceReminder.asp code from the command line you must comment out the following line:
Err.Raise &H80004005, , "Error: CampaignItemID was not specified"
and uncomment the following line:
' strUserID = Request.Cookies("MSCSProfile")
as descibed in the comments of the ServiceReminder.asp code.
For more information about sending a test message, see Testing a Direct Mail Campaign.