Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Apps Script suddenly started throwing 'invalid mime type' errors
    primarykey
    data
    text
    <p>I have a script which processes a shared mailbox and forwards on different email (based on things like the original 'To:' header to various people. It's been working fine for months as a more flexible (and, up till now, reliable) replacement for gmail filters.</p> <p>The logic is basically</p> <ol> <li>Read each unprocessed message in the inbox</li> <li>Look up who it was sent 'To:' (e.g. support@domain.com) which is an alias for this gmail inbox</li> <li>Get a list of the intended recipients (within our organistion)</li> <li>For each of those, forward the message on</li> <li>Mark that message as processed, so it doesn't get re-forwarded next time</li> </ol> <p>We've recently received an email which seems to trigger a weird error at the point at which the message is forwarded on. The error is 'Invalid mime type. (line 123, file "Code"). Line 123 of the script reads:</p> <pre><code>// subject: removes the 'Fwd:' prefix which we don't need, and adds the original target email in square brackets, and sets the replyTo for easy processing really &amp;&amp; msg.forward(rcvr, {subject: msg.getSubject() + " [" + thisTo + "]", replyTo: msg.getFrom()}); </code></pre> <p>Here's a summary of the interesting bits:</p> <ul> <li><code>really</code> is just a boolean so we can do 'dry runs' for testing</li> <li><code>msg</code> is set to the current message being processed, and is of type GmailMessage</li> <li><code>rcvr</code> is a string with the recipient's email address</li> <li><code>thisTo</code> is a string holding the original 'To:' header</li> </ul> <p>The message in question is a multi-part mime email with plain text and html in it. It displays just fine in gmail, and I can forward it on from there without problems. So, could anyone shed light on what the script engine is complaining about? The raw email looks like this (with some bits taken out for privacy) in case that helps pin it down:</p> <pre><code>Delivered-To: XXXX@YYYY.com Received: by 10.182.155.73 with SMTP id vj5sqase239pbc; Wed, 26 Jun 2013 08:50:48 -0700 (PDT) X-Received: by 10.68.166.5 with SMTP id zc5m425et238pbb.16.1372261847795; Wed, 26 Jun 2013 08:50:47 -0700 (PDT) Return-Path: &lt;support@ZZZZ.com&gt; Received: from mail.ZZZZ.com (mail.ZZZZ.com. [64.78.193.232]) by mx.google.com with ESMTP id vj5sqwefwe239pbc.316.2013.06.26.08.50.47 for &lt;multiple recipients&gt;; Wed, 26 Jun 2013 08:50:47 -0700 (PDT) Received-SPF: pass (google.com: domain of support@ZZZZ.com designates aa.bb.cc.dd as permitted sender) client-ip=aa.bb.cc.dd; Authentication-Results: mx.google.com; spf=pass (google.com: domain of support@ZZZZ.com designates aa.bb.cc.dd as permitted sender) smtp.mail=support@ZZZZ.com Date: Wed, 26 Jun 2013 09:50:46 -0600 To: AAAA@YYYY.com, XXXX@YYYY.com From: ZZZZ &lt;support@ZZZZ.com&gt; Reply-to: ZZZZ &lt;support@ZZZZ.com&gt; Subject: ZZZZ (Order #00412744) Message-ID: &lt;805b426783f23fec38ddafb002ce40b@admin.ZZZZ.com&gt; X-Priority: 3 X-Mailer: PHPMailer 5.1 (phpmailer.sourceforge.net) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="b1_805b426783ff4601fbe72afb002ce40b" --b1_805b426783ff4601fbe72afb002ce40b Content-Type: text/plain; charset = "utf-8" Content-Transfer-Encoding: 7bit Hello Andy, [SNIP] and destroy all copies of the original message. Thank You --b1_805b426783ff4601fbe72afb002ce40b Content-Type: text/html; charset = "utf-8" Content-Transfer-Encoding: 7bit &lt;html&gt; &lt;head&gt; &lt;/head&gt; [SNIP] and destroy all copies of the original message. Thank You&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/body&gt; &lt;/html&gt; --b1_805b426783ff4601fbe72afb002ce40b-- </code></pre> <p>Many thanks,</p> <p>Dave.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload