0

I am developing a chrome addon and I want to append my own content at the end to mail content using InboxSDK. I am using the following code, but it's appending to my cursor position in Gmail Compose Box.

var cv = event.composeView;
cv.insertTextIntoBodyAtCursor('My Content');

also, I want to append content before sending mail. So, How I can achieve it using InboxSDK.

Thanks in advance

Sunil Dora
  • 1,407
  • 1
  • 13
  • 26

1 Answers1

1

You could just get the whole messages body, modify and set the modified version as the new messages body. There is two ways to approach it.

1. getBodyElement()

Get the whole messages HTML and append whatever you want to append and set this as the new body HTML.

var $content = $(composeView.getBodyElement());
var $myContent = $('<div class="my_content">Hello World!</div>');

$content.append($myContent );
composeView.setBodyHTML($content.html());

2. getHTMLContent()

It would also work with the HTML string of the messages body.

var contentString = composeView.getHTMLContent();
var myContent = '<div class="my_content">Hello World!</div>';

contentString += myContent;
composeView.setBodyHTML(contentString);