5

I am sending email using the Gmail APIs. The email is sent correctly, however the From address is not shown as I mentioned "Anup S via TestApp " . Instead it is simply showing the userID/email.

var email_lines = [];
email_lines.push("From: Anup S via TestApp <[email protected]>");
email_lines.push("To: [email protected]");
email_lines.push('Content-type: text/html;charset=iso-8859-1');
email_lines.push('MIME-Version: 1.0');
email_lines.push("Subject: New future subject here");
email_lines.push("");
email_lines.push("And the body text goes here");
email_lines.push("<b>And the bold text goes here</b>");

var email =email_lines.join("\r\n").trim();


var base64EncodedEmail = btoa(email);
var requestEmail = gapi.client.gmail.users.messages.send({
    'userId': "me", // I also tried changing this - and (obviously) it does not work. 
    'message': {
        'raw': base64EncodedEmail
    }
});

Any ideas on how to fix this?

2 Answers 2

1

How about trying to add ' mark?

  email_lines.push("From: 'Anup S via TestApp' <[email protected]>");
Sign up to request clarification or add additional context in comments.

Comments

0

The From email address has to match the email address of the logged in user for the API, it can't be someone else. Is that true in your case? If that is true then you should be able to set whatever display name on the email you want, i.e.:

email_lines.push("From: \"Some Name Here\" <[email protected]>");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.