I am trying to read a custom header which i have added to all incoming messages in gmail by using routing settings
after adding the header I am reading this
X-MY-CUSTOM-HEADER in google apps script project.
const onGmailMessageOpen= (e)=>{
var accessToken = e.gmail.accessToken;
GmailApp.setCurrentMessageAccessToken(accessToken);
var messageId = e.gmail.messageId;
var message = GmailApp.getMessageById(messageId);
console.log(message.getHeader("X-MY-CUSTOM-HEADER"));
}
my questions are
1. if incoming message already has
X-MY-CUSTOM-HEADER set, what will happen to the header added using Gmail Routing? Will it always get appended at the end of header list? is there any documentation to confirm this?
2. If duplicate headers for
X-MY-CUSTOM-HEADER are present then which will get returned upon executing
message.getHeader("X-MY-CUSTOM-HEADER")? (I didn't find any documentation for which header value will be returned by
message.getHeader() if duplicate headers are present. RFC 2822 standard doesn't define strict behavior for duplicate headers.
behavior which i am seeing is that it picks the last header value, but i am not finding it documented anywhere , can some one point me to the official page where it may be documented)
Regards,
Ajay