I am using to send yahoo mail api using JSON format to send mail. But even I use \r\n
to make new line for the block of message that I want to send out, there is no effect when the recipient received it as a mail.
As there are some problem in making JSON if there are special characters, I am using StringEscapeUtils.escapeJavaScript
method to make my message string valid eg. hello friend.\r\n testing with special characters ~`!@#$%^&*() \n{}[]|?/.>,< .
{
"method": "SendMessage",
"params": [
{
"savecopy": true,
"message": {
"to": {
"email": "test@yahoo.com",
"name": "SendMessage Test User"
},
"from": {
"email": "ctest@yahoo.com",
"name": "SendMessage Test User"
},
"replyto": {
"email": "test@yahoo.com",
"name": "SendMessage Test User"
},
"inreplyto": "SendMessage InReplyTo Value",
"mailer": "YahooMailRC",
"subject": "Message with Stationery",
"simplebody": {
"text": "hello friend.\r\n testing with special characters ~`!@#$%^&*() \n{}[]|?/.>,<",
"html": "hello friend.\r\n testing with special characters ~`!@#$%^&*() \n{}[]|?/.>,<"
}
}
}
]
}
I use to escape \
when I create a valid string to make JSON object.
Note: If I only set data in text , not in html. Nothing appeared in received mail.
How can I format the text that I want to send out via Yahoo mail api to retain all the new line (HTML format style) ?
I solved the issue by adding <PRE>
tag to use the html format of my string.