I've got a problem concerning the following script.
function doGet() {
//Create draft email
var body = "Project ö";
var subject = "Subject ö";
var forScope = GmailApp.getInboxUnreadCount(); // needed for auth scope
var raw =
'Subject: ' + subject + '\n' +
'To: ' + "[email protected]" + '\n' +
'Content-Type: multipart/alternative; boundary=1234567890123456789012345678\n' +
'' + body + '\n' +
'--1234567890123456789012345678--\n';
var draftBody = Utilities.base64Encode(raw, Utilities.Charset.UTF_8);
var params = {method:"post",
contentType: "application/json",
headers: {"Authorization": "Bearer " + ScriptApp.getOAuthToken()},
muteHttpExceptions:true,
payload:JSON.stringify({
"message": {
"raw": draftBody
}
})
};
}
The problem is that some special characters that are important in German language ("ä, ö, ü ...") are not transferred correctly to the generated draft email.
In the draft Email the character "ö" is converted to "ö". It's the same in subject and body.
How can I tell Google Apps Script to create the correct characters?
Utilities.base64EncodeWebSafeinstead.