I have created an GSuite App script from an old post on here. This works great and forwards the email to an email Dropbox in my CRM (Workbooks). When done manually the email sends and the CRM deciphers the incoming email and somehow spots the original sender and then links it to the correct contact record. The issue I have with the script below is that it forwards the email but the CRM does not get the original sender so links it to a contact myaddress@gmail.com. The script clearly does not send in the same way as a normal forward does. Any help appreciated.

function autoForward() {
  var label = 'Workbooks';
  var recipient = 'box-12345@dropbox.workbooks.com';
  var interval = 5;          
  var date = new Date();
  var timeFrom = Math.floor(date.valueOf()/1000) - 60 * interval;
  var threads = GmailApp.search('label:' + label + ' after:' + timeFrom);
  for (var i = 0; i < threads.length; i++) {
    threads[i].getMessages()[0].forward(recipient);  // only the 1st message
  • Is the "from" address (both name and email) the same for both manual and script emails? – Tedinoz Sep 5 '19 at 22:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.