This topic is locked
[SOLVED]

Need to send new data after added as attachment

5/27/2021 4:55:08 PM
ASPRunnerPro General questions
M
Michael Perry author

I have a project i need to send the new record as a PDF attachment once added. this can't be on a button and has to happen automatically behind the scenes.

The PDF view page works and looks perfect.

Any help would be greatly appreciated.

admin 5/27/2021

PDF API is Javascript based which means you cannot use it in the server event.

What you can do is to redirect user to the View page add when page is being loaded create the PDF and send it via email.

More info

M
Michael Perry author 6/1/2021

That article seems to be for phprunner...

I am okay with the user being redirected to the view page once added.. i just need to pdf page to email itself without any user input...

any help would be amazing.

M
Michael Perry author 6/1/2021

set attachment = = CreateDictionary() <---- = = ??

really hard to follow help docs with typos...

Also the code/help page seems to be coded for a button......

How would one use that code to run when a record is added and then redirected to the view page... i dont get client before or server or client after???

admin 6/1/2021

Thank you for pointing, we'll fix the typo.

Yes, this specific example uses the button. This is just an example that explains the idea of how you can create a PDF file and email it. You can, for instance, add this kind of button to the View page and also add the code to Javascript OnLoad event that would click this button programmatically after the page is loaded.

How to click the button programmatically

M
Michael Perry author 6/1/2021

Thank you as always.!!! this is why i have been with you for almost 13 years!

M
Michael Perry author 6/10/2021

I had marked this solved but i can't get past this error... I am on the view page working on a button.

Microsoft VBScript runtime error '800a01a8'

Object required: 'mail'

/buttonhandler.asp, line 101

Client Before:

ajax.addPDF( 'pdf', {}, function() {
return ctrl.dialog( {
title: 'Email this page',
fields: [{
name: 'email',
value: 'email@address.com'
},
{
name: 'filename',
value: 'results.pdf'
}]
});
});
return false;

SERVER

path = button.saveTempFile( params("pdf") )

set mail = CreateDictionary()
mail("to") = params("email")
mail("subject") = "ASPRunner PDF and Email demo"
mail("body") = "Check the results"
set attachment = CreateDictionary()
attachment("path") = path
attachment("name") = params("filename")
set mail("attachments") = array( attachment )
ret = runner_mail( mail )
if ret("mailed") then
result("success") = true
else
result("message") = ret("message")
result("success") = false
end if