CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Persits AspEmail email query results

Print topic Send  topic

Author Message
Dorin

Posts: 50
Posted: 05/10/2012, 1:10 AM

Hello,

I am using AspEmail from Persits for sending emails which is working fine.
I want to add to Mailer.Body the result of a query. I tried the code bellow, but this error appears:

<<Microsoft VBScript runtime error '800a01c2'
Wrong number of arguments or invalid property assignment >>

pointing to the line where Mailer.Body is defined.

My code is:

Set Mailer = Server.CreateObject("Persits.MailSender")
.......

Set NewConnection1 = New clsDBConnection1
NewConnection1.Open
SQL = "SELECT * FROM view_orders WHERE id="&ID
Rs = NewConnection1.Execute(SQL)
ErrorMessage = CCProcessError(NewConnection1)
NewConnection1.Close
Set NewConnection1 = Nothing
On Error Goto 0
.....

Mailer.Body = "Order:<br><br>" & Rs & "<br>Thank you!"
Mailer.Send
set Mailer = Nothing

Could someone illuminate me? Thanks.
View profile  Send private message
TheunisP

Posts: 342
Posted: 05/10/2012, 12:36 PM

your problem is not the mail component, but with the RS - you cant just tell it to send the whole return result set you have to qualify it e.g. RS("fieldname") or step throught the result set and build a string to send back
View profile  Send private message
Dorin

Posts: 50
Posted: 05/10/2012, 10:56 PM

thanks TheunisP,

I think the error occurred because the result of the query is an array, something like that:

orderid | item | quantity | price
--------------------------------------------
100 | beer | 3 | 2
100 | ale | 5 | 10

my problem is that I have no idea how could I do this, how could I add these results to the email body



View profile  Send private message
TheunisP

Posts: 342
Posted: 05/10/2012, 11:11 PM

ok assuming your field names above is correct add something like this before the send:

dim fstrTemp

while not rs.eof and not rs.bof
fstrTemp=fstrTemp&Rs("item")&" x "&Rs("quantity")&" = "&Rs("price")&vbcrlf
rs.movenext
wend

then change the line to

Mailer.Body = "Order:" &vbrlf&fstrTemp&vbrlf&vbrlf&"Thank you!"


please noted that I use a text formated mail - hence the use of vbrlf instead of <br> - the code was not tested and typed from memory but should be good enough to get you started

View profile  Send private message
Dorin

Posts: 50
Posted: 05/10/2012, 11:15 PM

oh, I'll give it a try....many thanks
View profile  Send private message
TheunisP

Posts: 342
Posted: 05/10/2012, 11:18 PM

no prob - good luck
View profile  Send private message
Dorin

Posts: 50
Posted: 05/10/2012, 11:40 PM

yes...it works, one of those beers is yours!
View profile  Send private message
TheunisP

Posts: 342
Posted: 05/10/2012, 11:50 PM

cool ;-) glad to be of help

View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.