Smart Mailer ASP Support Product Page

This topic was archived

Dynamic Template

Asked 26 May 2007 11:23:04
1
has this question
26 May 2007 11:23:04 Håkan Petersson posted:
Need help with template in SmartMailer.

I have read the help and tutorial for SmartMailer and don’t find the answer I’m looking for.

I understand that I can include a Template into the body part of the mail. But how to include a
Template into the body part with dynamic data?

The formpage is only two fields:
Subject
Message

The database is made of one table with only: Name and email.

This is how I want the email to be:
The subject from the Subject value from the formpage
The body part includes Name from database.
And Message from Message value from the formpage.

The email comes of course from the database.

Example of mail:
Subject: This is from the form.

Body part: Hello Name (from the data sourse)

Here comes the message from the formpage

Regards and other stuff from the template.

Hope you understand me.

Regards

Replies

Replied 30 May 2007 15:17:53
30 May 2007 15:17:53 Georgi Kralev replied:
Hi Håkan,

This is a sample template which include some information from database and some from formpage:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>&lt;%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%&gt;
&lt;!--#include file="Connections/conn_VB_testDB.asp" --&gt;
&lt;%
Dim rsmailInfo
Dim rsmailInfo_cmd
Dim rsmailInfo_numRows

Set rsmailInfo_cmd = Server.CreateObject ("ADODB.Command"
rsmailInfo_cmd.ActiveConnection = MM_conn_VB_testDB_STRING
rsmailInfo_cmd.CommandText = "SELECT * FROM dbo.Mails"
rsmailInfo_cmd.Prepared = true

Set rsmailInfo = rsmailInfo_cmd.Execute
rsmailInfo_numRows = 0
%&gt;
&lt;% response.AddHeader "Content-Type", "text/html;Charset=iso-8859-1" %&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;%
dim sSender
sSender = Request.QueryString("SenderName"
%&gt;

Hello &lt;%=(rsmailInfo.Fields.Item("Name".Value)%&gt;&lt;br /&gt;
&lt;p&gt;
Here comes the message from the formpage: &lt;% =sSender %&gt;
&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;%
rsmailInfo.Close()
Set rsmailInfo = Nothing
%&gt;<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

The following value is read from the Database:
&lt;%=(rsmailInfo.Fields.Item("Name".Value)%&gt;

The sSender value should be pass into the URL when the template is set.
For example:

sm1.setBody_Template_html "DB_template.asp?SenderName=" & Mails.Fields.Item("SenderName".Value & ""

I hope this will help you.

Regards,

Georgi Kralev

----------------------------------
Support - www.DMXzone.com

Reply to this topic