Re: How to email a report directly from grid
Just get rid of sessionfolder or whatever it's called <SessionFolder> I think? I had that problem too back when I upgraded to V12. I don't think it's related. If you are on V12.3 like me, then the problem is most likely the one I'm experiencing now. The answer may be in the new "Prototype Function" notes that show up when targeting Xbasic with a report...
I think it may use some type of key now which is screwing things up.
This is messing up my mojo right now too so I'm going to try to fix this ASAP
Just get rid of sessionfolder or whatever it's called <SessionFolder> I think? I had that problem too back when I upgraded to V12. I don't think it's related. If you are on V12.3 like me, then the problem is most likely the one I'm experiencing now. The answer may be in the new "Prototype Function" notes that show up when targeting Xbasic with a report...
Code:
function reportForEmail as c (e as p) 'This function is called after the report has printed 'The e object that is passed in includes: 'e.tmpl - the component definition 'e.dataSubmitted - data from the component 'e.fileSessionKey - the key where the binary data for the report that was printed is stored in session storage. 'The function can return Javascript to execute in the browser. 'Using the e.fileSessionKey value you can retrieve the binary data for the report 'For example 'dim b as b 'session.GetDataFromFile(b,e.fileSessionKey) 'dim size as n 'size = b.size() 'if size = 0 then '' ---- there must have been an error - no data was retrieved 'end if 'Sample code to e-mail the report using the Mandril email service ----- 'dim key as c 'key = e.fileSessionKey 'dim b as b 'get the binary day for the report 'session.GetDataFromFile(b,key) 'dim size as n 'size = b.size() 'if size = 0 then ' reportForEmail = "alert('Report was not sent.');" ' exit function 'end if 'If you don't have a Mandrill secret key, sign up at Mandrill.com 'dim mysecretkey as c = "" 'if you leave this blank the key value is read from a setting in Project Properties 'dim ms as p 'ms.send_to = "specify comma delimited list of email addresses" 'ms.from_email = "your email address" 'ms.subject = "put email subject here" 'ms.message_html = "put email body here" 'dim ms.attachmentsArray[1] as p 'ms.attachmentsArray[1].name = "NameOfFile.pdf" 'if the report was an html report, use the .html extension 'ms.attachmentsArray[1].type = resolve_mime_type("pdf") 'if the report was an html report, use the 'html' 'ms.attachmentsArray[1].content = base64encode(b) 'dim pResult as p 'pResult = email_send_mandrill(mysecretkey,ms) 'if pResult.error = .f. then ' reportForEmail = "alert('Report sent.');" 'else ' __name = "alert('Report was not sent.');" 'end if end function
This is messing up my mojo right now too so I'm going to try to fix this ASAP
Comment