Thursday, March 29, 2012

SMTP EMAIL: How to Include Query Results in HTML Format in Body Tag

Here is my code fragment. Keeps genrating error that "End of Statement" expected. Is it EVEN possible to include query results in the HTML formated Email. Note: The code is in VB .NET? Could not find any example on the net. But, since I am too new to .NET, not even sure how to look for the right info yet.

Thanks.

Meengla

-----

mail.Body = "<table cellpadding=10><tr><td valign=top> <%# DataBinder.Eval(Container.DataItem, "StreetAddress") %> <br></td></tr></table>"


' SmtpMail.Send(mail)
%>

</ItemTemplate>

</ASP:DataList>

---

Try:

mail.Body = "<table cellpadding=10><tr><td valign=top>" & <%# DataBinder.Eval(Container.DataItem, "StreetAddress") %> & "<br></td></tr></table>"

You need to concatenate the string mail.Body from the HTML plus the results of the query, your version (besides having syntax errors with quotes) includes the text of the query itself as part of the string. Note that this is a quick look and that I can't verify if the query is valid here.

Jeff


Thanks. But now it says "Expression expected" error. I guess somehow I will have to create variables to hold each database field's data and then insert these variables into the dynamic html table in the email's Body. It sure sounds like a lot of work. In Cold Fusion I would have done somethink like:

<CFQUERY name="myquery" ...>...</cfquery>

<cfoutput query="myquery">

<CFMAIL to="myquery.email html="true" ....>

#myquery.fistname#<br>

....

</cfmail>

I am sure ASP .NET must have something similar? No, I don't want to use Cold Fusion here.

Thanks.

Meengla


Oops, n/m - sorry.


Anyone? Is ASP .NET REALLY that complicated?! I mean, look at my code above in Cold Fusion and replicate it to ASP .NET. All I want to do is to include database query results in an HTML email page. My God! The supposedly hottest technology out there in server-side programming can't do it or can do it but will take 5 days to explain to anyone?

Meengla


Never mind. I figured it out. Thanks. Meengla

0 comments:

Post a Comment