Poco Reading/Replying FAQ - Automatic forwarding attaching a message

Q:How can I automatically forward all incoming e-mails to another e-mail address with an additional note?
 
A:
  1. You will need to create a new script .
  2. You can control what messages it forwards by putting controls in the script or by attaching it to one or more filters that you specifically wish to have run the script. If you do the later then you will have to configure Poco to run the script against all incoming messages .

As far as the rest is concerned ...

{ Forward messages with an additional note...
{ 
{ This is not a complete script and will require additional
{ work to operate. This script can be attached to a filter
{ or have more conditions attached in the script itself.
{ Right now, it only forwards messages that are sent to
{ recipient@somewhere.com in either the To: or the CC:
{ fields

{ We're not using SendMessage, because when this script was
{ originally written, it didn't work right. It's supposed
{ to be fixed, but I haven't bothered to test it, because
{ the need for the script has been eliminated.
AppendToFile True

External $userdata1 "To/CC Filter" "recipient@somewhere.com" 
External $userdata2 "Destination Address" "bounced@elsewhere.com"
External $userdata3 "Subject Note" "FW: [Foo] "
External $userfile1 "Message File" "note_forward.txt"

Set $to_cc_filter $userdata1
Set $dest_address $userdata2
Set $subject_note $userdata3
Set $note_file $userfile1

{ Get the To, CC, and From values.
ReadTo $to %message
ReadCC $cc %message
ReadHeader $from "From" %message

{ Test for the filter value. If present, then do the work.
If $to_cc_filter ^ $to Then Continue
If $to_cc_filter ^ $cc Then Continue

Exit

:Continue
{ Get the old subject, to, and CC.
ReadHeader $OldSub "Subject" %message
Set $OldTo $to
Set $OldCC $cc

{ Clear the old to and CC values.
ClearTo %message
ClearCC %message

{ Set the new Subject string.
Set $subj $subject_note
AddStrings $subj $OldSub
DeleteHeader "Subject" %message
AddHeader %message "Subject" $subj

{ Read the raw message, add our note, and replace the body.
{ Note that this will PROBABLY screw up HTML messages, and
{ may not work well with messages that have attachments.
{ I also don't warrant that won't change things in your
{ incoming messages.
ReadRawBody $raw_body %message
OpenBody $new_body $note_file
AppendBody $new_body $raw_body
AssignBody %message $new_body

{ Set the destination address and send the message.
AddTo %message $dest_address
SaveMessage %message "Out.mbx"
DeleteHeader "Subject" %message
AddHeader %message "Subject" $OldSub
ClearTo %message
ClearCC %message
AddTo %message $OldTo
AddCC %message $OldCC
AssignBody %message $raw_body

Exit

I don't know if it will work -- and it might royally screw things up -- but that's the basic idea. If, once you're satisfied that it isn't messing things up, you want to change a line, you can change the SaveMessage line to SendMessage message.