My xpage has following fields
- Xpage with evo:InputRichtext ckeditor from this snippet:
- I'm using gmail api to send email.
- I'm adding formatted text, inline images and files in Ckeditor
- Using button to get values from To, Subject and Ckeditor component using csjs.
- Message sent thru gmail server but not receiving wysiwyg format. The image is not displayed and only file name appears.
I know it is cross platform encoding issue and I don't know what is that.
Here is button code:
var to = XSP.getElementById("#{id:To}").value;
var subject = XSP.getElementById("#{id:Subject}").value;
var richCKEditor = CKEDITOR.instances["#{id:inputRichText1}"];
var dt=richCKEditor.getData();
var content = richCKEditor.dataProcessor.toHtml(dt);
console.log(to);
console.log(subject);
console.log(content);
var email ="From: 'm' <"+to+">\r\n"+
"To: "+ to +"\r\n"+
"Subject: "+subject+"\r\n"+"\r\n"+
"MIME-Version: 1.0\n"+
//"Content-Type: text/html; charset=\"UTF-8\"\n" +
"Content-Type: multipart/mixed; \n" +
content;
console.log(email);
auth();
send(email);
Here gmail api function I'm using with existing authentication from gmail api site
function send(email) {
console.log(email);
sendMessage(email, function (response) {
//console.log("Handed to Gmail API for sending");
{console.log(response)}
});
alert("Message sent");
}
function sendMessage(email, callback) {
//auth();
gapi.client.load('gmail', 'v1',function(){
var base64EncodedEmail = btoa("MIME-Version: 1.0\n"+
"Content-Type: text/html; charset=\"UTF-8\"\n" +
// "Content-Type: multipart/mixed; \n" +
//"Content-length: 5000\n" +
//"Content-Transfer-Encoding: message/rfc822\n"+
email).replace(/\//g,'_').replace(/\+/g,'-');
// alert("Message sending\n" + base64EncodedEmail.toString());
console.log(base64EncodedEmail);
var request = gapi.client.gmail.users.messages.send({
'userId': 'me',
'resource': {
'raw': base64EncodedEmail
}
});
request.execute(callback);
});
}
This is a test.
This is sametime emoticon which is gif. file. test.txtThis is simple .txt file. Both are inline.
which has source. – Mohan Gangan Oct 30 '15 at 22:24