Community Discussions and Support
Filtering rules - forwarding message without attachment

Thank you, Rolf and Thomas.

I shall do some more experiments and will post the results.

 Chris

<p>Thank you, Rolf and Thomas.</p><p>I shall do some more experiments and will post the results.</p><p> Chris </p>

I like to have incoming mail on a particular subject available to me on my home system (running Mercury) and on my work PC - I work for a large company and have no opportunity to change anything at that end.

So mail on that subject is sent to a distinctive address which is aliased to a General Rule. The work system doesn't seem to like attachments bigger than 3Mb so I filter them out and just send a notification that there's a big mail which has not been forwarded. The RUL file is:

Always Copy "Chris"
If size > 2999999 SendMessage "[work].com:c:\\mercury\\toobig.txt"
If size < 3000000 Forward "[work].com"

This works, but it would be nice to know what was in the big mail. I'd like to strip the attachment off the mail and forward just the text, rather than sending a notification, but I can't see how to do that.

Any suggestions?

Thanks

Chris

 

&lt;p&gt;I like to have incoming mail on a particular subject available to me on my home system (running Mercury) and on my work PC - I work for a large company and have no opportunity to change anything at that end. &lt;/p&gt;&lt;p&gt;So mail on that subject is sent to a distinctive address which is aliased to a General Rule. The work system doesn&#039;t seem to like attachments bigger than 3Mb so I filter them out and just send a notification that there&#039;s a big mail which has not been forwarded. The RUL file is:&lt;/p&gt;&lt;p&gt;Always Copy &quot;Chris&quot; If size &amp;gt; 2999999 SendMessage &quot;[work].com:c:\\mercury\\toobig.txt&quot; If size &amp;lt; 3000000 Forward &quot;[work].com&quot; &lt;/p&gt;&lt;p&gt;This works, but it would be nice to know what was in the big mail. I&#039;d like to strip the attachment off the mail and forward just the text, rather than sending a notification, but I can&#039;t see how to do that.&lt;/p&gt;&lt;p&gt;Any suggestions?&lt;/p&gt;&lt;p&gt;Thanks &lt;/p&gt;&lt;p&gt;Chris &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;

In theory this should do it:

------ 

Always Copy "Chris"

If size > 2999999 Goto "DeleteAttachment"

Always Forward "[work].com"

Always Exit ""

Label "DeleteAttachment"

If attachment NamePart matches "*" DeleteAttmt ""

Always Forward "[work].com"

-----

However, even though the match test definitely triggers the attachment is not deleted. So at present you would probably have to write a daemon to do it.

/Rolf 

&lt;p&gt;In theory this should do it:&lt;/p&gt;&lt;p&gt;------&nbsp;&lt;/p&gt;&lt;p&gt;Always Copy &quot;Chris&quot;&lt;/p&gt;&lt;p&gt;If size &gt; 2999999 Goto &quot;DeleteAttachment&quot;&lt;/p&gt;&lt;p&gt;Always Forward &quot;[work].com&quot;&lt;/p&gt;&lt;p&gt;Always Exit &quot;&quot;&lt;/p&gt;&lt;p&gt;Label &quot;DeleteAttachment&quot;&lt;/p&gt;&lt;p&gt;If attachment NamePart matches &quot;*&quot; DeleteAttmt &quot;&quot;&lt;/p&gt;&lt;p&gt;Always Forward &quot;[work].com&quot;&lt;/p&gt;&lt;p&gt;-----&lt;/p&gt;&lt;p&gt;However, even though the match test definitely triggers the attachment is not deleted. So at present you would probably have to write a daemon to do it.&lt;/p&gt;&lt;p&gt;/Rolf&nbsp;&lt;/p&gt;

[quote user="Rolf Lindby"]

In theory this should do it:

------ 

Always Copy "Chris"

If size > 2999999 Goto "DeleteAttachment"

Always Forward "[work].com"

Always Exit ""

Label "DeleteAttachment"

If attachment NamePart matches "*" DeleteAttmt ""

Always Forward "[work].com"

-----

However, even though the match test definitely triggers the attachment is not deleted. So at present you would probably have to write a daemon to do it.

I believe the mail has to be written to the new mail directory as a CNM file to get the attachment deleted from the message. The only way i can see to do this is to extract and delete the attachment  and then use a PMail new mail filter to forward the message without the attachment

/Rolf 

[/quote]
&lt;blockquote&gt;[quote user=&quot;Rolf Lindby&quot;]&lt;p&gt;In theory this should do it:&lt;/p&gt;&lt;p&gt;------&amp;nbsp;&lt;/p&gt;&lt;p&gt;Always Copy &quot;Chris&quot;&lt;/p&gt;&lt;p&gt;If size &amp;gt; 2999999 Goto &quot;DeleteAttachment&quot;&lt;/p&gt;&lt;p&gt;Always Forward &quot;[work].com&quot;&lt;/p&gt;&lt;p&gt;Always Exit &quot;&quot;&lt;/p&gt;&lt;p&gt;Label &quot;DeleteAttachment&quot;&lt;/p&gt;&lt;p&gt;If attachment NamePart matches &quot;*&quot; DeleteAttmt &quot;&quot;&lt;/p&gt;&lt;p&gt;Always Forward &quot;[work].com&quot;&lt;/p&gt;&lt;p&gt;-----&lt;/p&gt;&lt;p&gt;However, even though the match test definitely triggers the attachment is not deleted. So at present you would probably have to write a daemon to do it.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;I believe the mail has to be written to the new mail directory as a CNM file to get the attachment deleted from the message. The only way i can see to do this is to extract and delete the attachment&amp;nbsp; and then use a PMail new mail filter to forward the message without the attachment &lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;/Rolf&amp;nbsp;&lt;/p&gt;[/quote]&lt;/blockquote&gt;

As removing (or in this case changing the contents of) one or several MIME parts requires the MIME structure of the message to be recreated it makes sense that this isn't done until the message is written to it's destination. A general rule doesn't have a default destination, though, and Copy or Move actions "do not change the message in any way at all" (quoted from Mercury help). A quick test confirms that the attachment is still there in the CNM file.

In other words general rules can in fact not ever be used with the delete attachment action. Another quick test confirmed that it can be done with a global rule when the message is delivered to it's original destination. Unfortunately this deleted not only the attached file but the text part of the message as well (which was in a text/plain MIME part). With a modified regular expression, that requires the filename to contain at least one character, it might work though. By having a forward rule with Deliver-Also set to N for that mailbox the message would then be forwarded to an external destination without the attachments.

/Rolf 

&lt;p&gt;As removing (or in this case changing the contents of) one or several MIME parts requires the MIME structure of the message to be recreated it makes sense that this isn&#039;t done until the message is written to it&#039;s destination. A general rule doesn&#039;t have a default destination, though, and Copy or Move actions &quot;do not change the message in any way at all&quot; (quoted from Mercury help). A quick test confirms that the attachment is still there in the CNM file.&lt;/p&gt;&lt;p&gt;In other words general rules can in fact not ever be used with the delete attachment action. Another quick test confirmed that it can be done with a global rule when the message is delivered to it&#039;s original destination. Unfortunately this deleted not only the attached file but the text part of the message as well (which was in a text/plain MIME part). With a modified regular expression, that requires the filename to contain at least one character, it might work though. By having a forward rule with Deliver-Also set to N for that mailbox the message would then be forwarded to an external destination without the attachments.&lt;/p&gt;&lt;p&gt;/Rolf&nbsp;&lt;/p&gt;
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft