问题
I'm generating the reports in JasperServer and using the Rest api to schedule the report. The rest api is given below:
curl
-XPUT "http://hostURL/jasperserver/rest_v2/jobs"
--data '{
"trigger":{
"simpleTrigger":{
"occurrenceCount":"1",
"startType":"1",
"timezone":"Asia/Calcutta",
"misfireInstruction":"0",
"version":"0"
}
},
"outputTimeZone":"Asia/Calcutta",
"username":"jasperadmin",
"outputFormats":{
"outputFormat":[
"PDF"
]
},
"source":{
"parameters":{
"parameterValues":{
"parameter1":[
"value"
],
"parameter2":[
"value"
],
}
},
"reportUnitURI":"/reports/Report"
},
"baseOutputFilename":"MyReport",
"mailNotification":{
"messageText":"<p> Greeting,<br>Please find your statements.<p>",
"toAddresses":{
"address":[
"myemail@xyz.com"
]
},
"includingStackTraceWhenJobFails":"false",
"skipEmptyReports":"false",
"subject":"Account Statement",
"skipNotificationWhenJobFails":"false",
"resultSendType":"SEND_ATTACHMENT"
},
"repositoryDestination":{
"usingDefaultReportOutputFolderURI":"false",
"folderURI":"/Reports/GeneratedReports",
"saveToRepository":"true",
"overwriteFiles":"true",
"sequentialFilenames":"false"
},
"label":"Report_20160929591135"
}'
-H "authorization:Basic amFzcGVyYWRtaW46amFzcGVyYWRtaW4="
-H "content-type:application/job+json"
The API works perfectly. But the HTML content that I send in the messageText is not rendered and shows up as plain string. Is there any way I could send HTML content in the messageText. Do I have to make changes in some property files?
回答1:
As far as I know, Jaspersoft Server is not capable of sending HTML Emails as it is using basic Java Strings.
You basically have to edit the source code and change it to your liking.
For the line breaks maybe just use \n
?
来源:https://stackoverflow.com/questions/40577448/sending-html-content-in-the-email-body-in-jasperservers-scheduled-reports