Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF statement in myMail.HTMLBody

Status
Not open for further replies.

tinapa

Technical User
Nov 12, 2008
81
GB
Hi guys, I have this email application and i would like to put an IF sttement in it in the myMail.HTMLBody. How do you do that.

this bit from the code below gives an error, it says 'Syntax error':

& if Recordsettest("ID") = 123 then writethis end if &

Thanks for any inputs.


code:
.
.
Set myMail=CreateObject("CDO.Message")
myMail.Subject=Recordsettest("Subject")
myMail.From="fromMe@mysitetest.com"
myMail.To="toMe@mysitetest.com"

myMail.HTMLBody = "Dear Sir,<p>According to my records the above record which is held on database is due for review by " & DoDateTime(Recordsettest("tillnextreview").Value , 2, 2057) & ", and in line with our quality assurance process I am informing you at least 2 months in advance.<br>The item can be viewed via the link below.<p><a href= & Recordsettest("ID") & "> & Recordsettest("ID") & "</a> <p><br>" & if Recordsettest("ID") = 123 then writethis end if & "Please supply me with a new review date."
.
.
.
.
 
Hello Tinapa,

I think the problem is the writethis in your code.

Also I would suggest possibly using IIF function. Syntax is IIF(statement, true, false).



CHAOS, PANIC, & DISORDER - my work here is done.
 
Don't know where the op gets the idea of that syntax! Why not plain and simple?
[tt]
writethis="To: id123<br />" 'or something else if writethis is a variable

dim sHTMLBody

sHTMLBody = [ignore]"Dear Sir,<p>According to my records the above record which is held on database is due for review by " & DoDateTime(Recordsettest("tillnextreview").Value , 2, 2057) & ", and in line with our quality assurance process I am informing you at least 2 months in advance.<br>The item can be viewed via the link below.<p><a href= & Recordsettest("ID") & "> & Recordsettest("ID") & "</a> <p><br>"[/ignore]

if Recordsettest("ID") = 123 then
sHTMLBody=sHTMLBody & writethis
end if

sHTMLBody=sHTMLBody & "Please supply me with a new review date."

myMail.HTMLBody=sHTMLBody
[/tt]
 
Does this new code work?!

CHAOS, PANIC, & DISORDER - my work here is done.
 
thanks guys for your advice. i took a different route and tried sql statement and it worked.

have a nice weekend guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top