Is it possible to forward an email without the attachments?

83 views
Skip to first unread message

Michael Miller

unread,
Mar 4, 2020, 9:48:41 AM3/4/20
to Google Apps Script Community

We have a system in place where users send emails with attachments to a specific email. The attachment is processed, and then I want it to forward that email to me to alert me that it's been processed - however I do not want it duplicating the attachment in the forwarded email. Is this possible?

I've already tried setting the attachments property to null in the options, as well as just sending a new email with the same subject (which unfortunately isn't grouped into the same thread, so that wont work for me).

Jean-Luc Vanhulst

unread,
Mar 4, 2020, 3:06:38 PM3/4/20
to google-apps-sc...@googlegroups.com
You'll want to make sure to use the ThreadID of the original email


when you create the stripped email. Just copy subject and body AND the ThreadID  (but not the attachments)..


On Wed, Mar 4, 2020 at 9:48 AM 'Michael Miller' via Google Apps Script Community <google-apps-sc...@googlegroups.com> wrote:

We have a system in place where users send emails with attachments to a specific email. The attachment is processed, and then I want it to forward that email to me to alert me that it's been processed - however I do not want it duplicating the attachment in the forwarded email. Is this possible?

I've already tried setting the attachments property to null in the options, as well as just sending a new email with the same subject (which unfortunately isn't grouped into the same thread, so that wont work for me).

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/98ddeae6-92b6-44f1-921a-49cc840a6b1a%40googlegroups.com.

Michael Miller

unread,
Mar 5, 2020, 11:46:38 AM3/5/20
to Google Apps Script Community
Thank you, I think this is what I was missing. The link you included seems to be for Gmail API. By chance, do you know if it's possible to set the ThreadId in Google Apps Script? I'm using the GmailApp.sendEmail method, which doesnt seem to support it.



On Wednesday, March 4, 2020 at 2:06:38 PM UTC-6, Jean-Luc Vanhulst wrote:
You'll want to make sure to use the ThreadID of the original email


when you create the stripped email. Just copy subject and body AND the ThreadID  (but not the attachments)..


On Wed, Mar 4, 2020 at 9:48 AM 'Michael Miller' via Google Apps Script Community <google-apps-sc...@googlegroups.com> wrote:

We have a system in place where users send emails with attachments to a specific email. The attachment is processed, and then I want it to forward that email to me to alert me that it's been processed - however I do not want it duplicating the attachment in the forwarded email. Is this possible?

I've already tried setting the attachments property to null in the options, as well as just sending a new email with the same subject (which unfortunately isn't grouped into the same thread, so that wont work for me).

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

Jean-Luc Vanhulst

unread,
Mar 5, 2020, 11:52:13 AM3/5/20
to google-apps-sc...@googlegroups.com
On Thu, Mar 5, 2020 at 11:46 AM 'Michael Miller' via Google Apps Script Community <google-apps-sc...@googlegroups.com> wrote:
Thank you, I think this is what I was missing. The link you included seems to be for Gmail API. By chance, do you know if it's possible to set the ThreadId in Google Apps Script? I'm using the GmailApp.sendEmail method, which doesnt seem to support it.

https://developers.google.com/apps-script/reference/gmail/gmail-app#sendEmail(String,String,String,Object)

On Wednesday, March 4, 2020 at 2:06:38 PM UTC-6, Jean-Luc Vanhulst wrote:
You'll want to make sure to use the ThreadID of the original email


when you create the stripped email. Just copy subject and body AND the ThreadID  (but not the attachments)..


On Wed, Mar 4, 2020 at 9:48 AM 'Michael Miller' via Google Apps Script Community <google-apps-sc...@googlegroups.com> wrote:

We have a system in place where users send emails with attachments to a specific email. The attachment is processed, and then I want it to forward that email to me to alert me that it's been processed - however I do not want it duplicating the attachment in the forwarded email. Is this possible?

I've already tried setting the attachments property to null in the options, as well as just sending a new email with the same subject (which unfortunately isn't grouped into the same thread, so that wont work for me).

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/78c156d2-6881-43bb-8b6f-c6ace0931eae%40googlegroups.com.

Michael Miller

unread,
Mar 5, 2020, 12:04:43 PM3/5/20
to Google Apps Script Community
I tried that, but I cant seem to remove the To address. If possible, I would like to forward the email to me and not include the original sender in the email. Maybe that's not possible, and I just need to settle with including them in the response..


On Thursday, March 5, 2020 at 10:52:13 AM UTC-6, Jean-Luc Vanhulst wrote:
On Thu, Mar 5, 2020 at 11:46 AM 'Michael Miller' via Google Apps Script Community <google-apps-sc...@googlegroups.com> wrote:
Thank you, I think this is what I was missing. The link you included seems to be for Gmail API. By chance, do you know if it's possible to set the ThreadId in Google Apps Script? I'm using the GmailApp.sendEmail method, which doesnt seem to support it.

https://developers.google.com/apps-script/reference/gmail/gmail-app#sendEmail(String,String,String,Object)

On Wednesday, March 4, 2020 at 2:06:38 PM UTC-6, Jean-Luc Vanhulst wrote:
You'll want to make sure to use the ThreadID of the original email


when you create the stripped email. Just copy subject and body AND the ThreadID  (but not the attachments)..


On Wed, Mar 4, 2020 at 9:48 AM 'Michael Miller' via Google Apps Script Community <google-apps-sc...@googlegroups.com> wrote:

We have a system in place where users send emails with attachments to a specific email. The attachment is processed, and then I want it to forward that email to me to alert me that it's been processed - however I do not want it duplicating the attachment in the forwarded email. Is this possible?

I've already tried setting the attachments property to null in the options, as well as just sending a new email with the same subject (which unfortunately isn't grouped into the same thread, so that wont work for me).

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

Jean-Luc Vanhulst

unread,
Mar 5, 2020, 12:14:37 PM3/5/20
to google-apps-sc...@googlegroups.com
create draft (receive GmailDraft)  then use Update?
Then Send? I would image it would still be in the same Thread?
On Thu, Mar 5, 2020 at 12:04 PM 'Michael Miller' via Google Apps Script Community <google-apps-sc...@googlegroups.com> wrote:
I tried that, but I cant seem to remove the To address. If possible, I would like to forward the email to me and not include the original sender in the email. Maybe that's not possible, and I just need to settle with including them in the response..

On Thursday, March 5, 2020 at 10:52:13 AM UTC-6, Jean-Luc Vanhulst wrote:
On Thu, Mar 5, 2020 at 11:46 AM 'Michael Miller' via Google Apps Script Community <google-apps-sc...@googlegroups.com> wrote:
Thank you, I think this is what I was missing. The link you included seems to be for Gmail API. By chance, do you know if it's possible to set the ThreadId in Google Apps Script? I'm using the GmailApp.sendEmail method, which doesnt seem to support it.

https://developers.google.com/apps-script/reference/gmail/gmail-app#sendEmail(String,String,String,Object)

On Wednesday, March 4, 2020 at 2:06:38 PM UTC-6, Jean-Luc Vanhulst wrote:
You'll want to make sure to use the ThreadID of the original email


when you create the stripped email. Just copy subject and body AND the ThreadID  (but not the attachments)..


On Wed, Mar 4, 2020 at 9:48 AM 'Michael Miller' via Google Apps Script Community <google-apps-sc...@googlegroups.com> wrote:

We have a system in place where users send emails with attachments to a specific email. The attachment is processed, and then I want it to forward that email to me to alert me that it's been processed - however I do not want it duplicating the attachment in the forwarded email. Is this possible?

I've already tried setting the attachments property to null in the options, as well as just sending a new email with the same subject (which unfortunately isn't grouped into the same thread, so that wont work for me).

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/24f4a8d7-a763-443e-b8df-2dcdc697d4c5%40googlegroups.com.

Michael Miller

unread,
Mar 5, 2020, 1:11:26 PM3/5/20
to Google Apps Script Community
That's what I thought too, but it doesn't  seem to group it in the same thread. Maybe it's because the reply is coming from an email address that is not associated with the original thread. The email is sent to email A, who has a filter set up to forward it to email B, and the reply comes from email C.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

Jean-Luc Vanhulst

unread,
Mar 5, 2020, 1:12:55 PM3/5/20
to google-apps-sc...@googlegroups.com
I think the problem starts when A is forwarded to B. That's where the thread is probably lost?
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/a29586e3-83d9-40f2-9b32-4c69ac7e71f9%40googlegroups.com.

Michael Miller

unread,
Mar 5, 2020, 1:19:03 PM3/5/20
to google-apps-sc...@googlegroups.com
It's possible, but I think it's got to be after that. If I use the GmailMessage.forward() method it seems to work. The problem with this is it also includes the attachment, which I'm assuming will fill up my inbox twice as fast. That may be a sacrifice I need to make though.

Best Regards,

 

Michael Miller

Advantage Cable Services, Inc.

 

P Go Green! Print this email only when necessary. Thank you for helping to be environmentally responsible.



Alex

unread,
Mar 6, 2020, 1:24:58 PM3/6/20
to google-apps-sc...@googlegroups.com
It's strange because an empty array as the attachments works great for me

/**
 *
 */

function run() {
  forwardWithoutAttachments_
('subject:Indian language support');
}

/**
 * Forward without attachments
 * @param {string} query
 * @return {GoogleAppsScript.GmailApp.GmailMessage}
 */

function forwardWithoutAttachments_(query) {
 
/**
   * @type {GoogleAppsScript.Gmail.GmailMessage}
   */

 
const message = GmailApp.search(query)
   
.reduce((p, c) => {
      p
= p.concat(c.getMessages());
      console
.log(c.getFirstMessageSubject());
     
return p;
   
}, [])
   
.find(msg => msg.getAttachments().length);
 
return message.forward('alexanderivanov...@gmail.com', { attachments: [] });
}


Best, Alex

Michael Miller

unread,
Mar 6, 2020, 2:35:36 PM3/6/20
to google-apps-sc...@googlegroups.com
That's odd. I just checked, and it doesn't seem to work for me. I still get the attachment. I tried both setting attachments to null, as well as to an empty array.

Best Regards,

 

Michael Miller

Advantage Cable Services, Inc.

 

P Go Green! Print this email only when necessary. Thank you for helping to be environmentally responsible.


On Fri, Mar 6, 2020 at 12:25 PM Alex <oshli...@gmail.com> wrote:
It's strange because an empty array as the attachments works great for me

/**
 *
 */

function run() {
  forwardWithoutAttachments_
('subject:Indian language support');
}


/**
 * Forward without attachments
 * @param {string} query
 * @return {GoogleAppsScript.GmailApp.GmailMessage}
 */

function forwardWithoutAttachments_(query) {
 
/**
   * @type {GoogleAppsScript.Gmail.GmailMessage}
   */

 
const message = GmailApp.search(query)
   
.reduce((p, c) => {
      p
= p.concat(c.getMessages());
      console
.log(c.getFirstMessageSubject());
     
return p;
   
}, [])
   
.find(msg => msg.getAttachments().length);

 
return message.forward('alexander...@gmail.com', { attachments: [] });
}


Best, Alex

On Wednesday, March 4, 2020 at 5:48:41 PM UTC+3, Michael Miller wrote:

We have a system in place where users send emails with attachments to a specific email. The attachment is processed, and then I want it to forward that email to me to alert me that it's been processed - however I do not want it duplicating the attachment in the forwarded email. Is this possible?

I've already tried setting the attachments property to null in the options, as well as just sending a new email with the same subject (which unfortunately isn't grouped into the same thread, so that wont work for me).

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

Alex

unread,
Mar 6, 2020, 2:51:57 PM3/6/20
to Google Apps Script Community
I'd like to try.

Can you forward for me a sample email?


 
return message.forward('alexanderivanov...@gmail.com', { attachments: [] });
}


Best, Alex

On Wednesday, March 4, 2020 at 5:48:41 PM UTC+3, Michael Miller wrote:

We have a system in place where users send emails with attachments to a specific email. The attachment is processed, and then I want it to forward that email to me to alert me that it's been processed - however I do not want it duplicating the attachment in the forwarded email. Is this possible?

I've already tried setting the attachments property to null in the options, as well as just sending a new email with the same subject (which unfortunately isn't grouped into the same thread, so that wont work for me).

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

Michael Miller

unread,
Mar 9, 2020, 1:47:02 PM3/9/20
to google-apps-sc...@googlegroups.com
Unfortunately, I can't set it up to forward anything to you.  The most I could do is send you a sample email with an attachment, but I doubt that would really be much different than what you are testing with.

I was not able to figure it out, but I ran out of time and was forced to settle on forwarding the email with the attachment.  Thank you all for your help.

Best Regards,

 

Michael Miller

Advantage Cable Services, Inc.

 

P Go Green! Print this email only when necessary. Thank you for helping to be environmentally responsible.



 
return message.forward('alexander...@gmail.com', { attachments: [] });
}


Best, Alex

On Wednesday, March 4, 2020 at 5:48:41 PM UTC+3, Michael Miller wrote:

We have a system in place where users send emails with attachments to a specific email. The attachment is processed, and then I want it to forward that email to me to alert me that it's been processed - however I do not want it duplicating the attachment in the forwarded email. Is this possible?

I've already tried setting the attachments property to null in the options, as well as just sending a new email with the same subject (which unfortunately isn't grouped into the same thread, so that wont work for me).

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/8d6d8c3d-6f5a-4ef0-8756-6387d2907f3d%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages