Forums

ASP

This topic is locked

Dynamic text in CDONTS email

Posted 09 Dec 2002 22:59:51
1
has voted
09 Dec 2002 22:59:51 Rian Carstens posted:
Hi

Hope you can help. I have to build a CDONTS email that will contain dynamic text. Let me explain ...

Basicly the administrator should be able to go to the existing control pannel, then fill out a form where he will be able to create the body of the email. The body of the email might be plain text, but could also contain dynamic text. Like for instance, "Dear Customer" where "Customer" will be dynamic and be replaced by "Mr Brown"

Here is the code I have so far:

<pre id=code><font face=courier size=2 id=code> &lt;%
set rsHouse = Server.CreateObject("ADODB.Recordset"
rsHouse.ActiveConnection = MM_connCasa_STRING
rsHouse.Source = "SELECT TOP 1 hID, hName, hDescription FROM Houses ORDER BY hID DESC"
rsHouse.CursorType = 0
rsHouse.CursorLocation = 2
rsHouse.LockType = 1
rsHouse.Open()
rsHouse_numRows = 0
%&gt;
&lt;%
while not rsHouse.eof

Dim CustomersCopy, CasaOwnersCopy, hDescription, hName

hDescription = rsHouse.Fields.Item("hDescription".Value
hName = rsHouse.Fields.Item("hName".Value


CustomersCopy = "Dear " & hName & vbCrLf & vbCrLf
CustomersCopy = CustomersCopy & hDescription

CasaOwnersCopy = "Estimado Propietario" & vbCrLf & vbCrLf
CasaOwnersCopy = CasaOwnersCopy & hDescription

Set MailObjCustomer = Server.CreateObject("CDONTS.NewMail"
MailObjCustomer.From = " "
MailObjCustomer.To = " "
MailObjCustomer.Cc = ""
MailObjCustomer.Bcc = ""
MailObjCustomer.Subject = "subject"
MailObjCustomer.Importance = 2

MailObjCustomer.Body = CustomersCopy
MailObjCustomer.Send

Set MailObjCasaOwners = Server.CreateObject("CDONTS.NewMail"
MailObjCasaOwners.From = " "
MailObjCasaOwners.To = " "
MailObjCasaOwners.Cc = ""
MailObjCasaOwners.Bcc = ""
MailObjCasaOwners.Subject = "subject"
MailObjCasaOwners.Importance = 2

MailObjCasaOwners.Body = CasaOwnersCopy
MailObjCasaOwners.Send
rsHouse.MoveNext
wend
%&gt;
</font id=code></pre id=code>

How would I be able to allow the administrator to use "hName" in his text wherever he wanted to?

Thank you in advance

Replies

Replied 10 Dec 2002 15:47:40
10 Dec 2002 15:47:40 Dave Blohm replied:
this might be one solution:

&lt;%
Replace(YourString,"xcustomerx", hName)
%&gt;

give the guy(s) sending the email a 'keyword' (in this case xcustomerx) that will be replaced with the desired string (in this case hName). Here the user could insert the name of the user throughtout the email if so desired.

Hope this helps...

Doc
Rangewalk Digital Studios
Replied 10 Dec 2002 19:01:26
10 Dec 2002 19:01:26 Rian Carstens replied:
Thanks mate! So simple, I guese I wanted to overcomplicate things.

Rian

Reply to this topic