Sending HTML content in the email body in Jasperserver's scheduled reports

你离开我真会死。 提交于 2019-12-11 04:23:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!