Reputation: 83
I have searched the site, and the web, but have had no joy.
I have a google apps script attached to a spreadsheet that (among other things) forwards emails with a given label to a given email address. I recently sent an email with a very long subject line, and the script has started failing on the following line of code:
msgsToStore[l].forward(emailAddress);
The error I receive is "Argument too large: subject"
The subject of the original email is 283 characters. Forwarding the message within the gmail web interface works without difficulty, adding "Fwd: " to the beginning as you would expect. The subject contains an ampersand, but is otherwise not unusual.
I need something I can use other than .forward, or some way of modifying the message object before forwarding it, but I can't find any documentation as to what the maximum size is.
Any help is greatly appreciated.
Upvotes: 1
Views: 1786
Reputation: 195
Trim the subject:
trimmed_subject = msgsToStore[l].getSubject().substring(0, 250)
msgsToStore[l].forward(emailAdress, {
subject: trimmed_subject,
});
More details: https://developers.google.com/apps-script/reference/gmail/gmail-message#forward(String,Object)
Upvotes: 2