[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Poco Forums • View topic - Change or add to subject using filter

Change or add to subject using filter

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Change or add to subject using filter

Postby austenlen » Sat Mar 24, 2007 3:02 am

Is there a way I can search for a phrase in the body of an email and then once found change the subject and forward the email with the new subject line to another email address?


i.e.

Look for:
"Credit Card; Yes"

Then change subject to:
"Credit Card Application Found"

Then forward the email with the new subject onto another email address.

Please. :lol:
austenlen
Drop-in Visitor
 
Posts: 12
Joined: Sat Dec 09, 2006 4:14 am

Postby Michael » Sat Mar 24, 2007 4:09 am

Yes, you can do this. It will require a script but it wouldn't be too difficult.

Assumptions:
1. You want to automatically run this process against incoming messages.
2. You only have one phrase you are searching for (the concept could be extended to multiple phrases in the future but that would require a more complex script - this could include different subjects and forwarding addresses for each search phrase).
3. The subject line will be static (i.e., you will not be pulling any specific text from the message nor will you be prompted to enter the text when the message arrives).

I would start with a filter that looks for the phase in the body of the message. That filter should run the script you will write.

The script will have to:
a) Extract the body of the message (ReadBody or ReadRawBody)
b) Extract the sender's name and email address (ReadHeader)
c) Create a new message (CreateMessage)
d) Assign the address to which you want to send the message (AddTo)
e) Assign the subject (AddHeader)
f) If you want to put the sender's name and email address into the message then you will have to manipulate the body of the message that you read in step a). To extract and add the date from the message you would have to use the ReadHeader command to get the date header from the message.
g) Copy the body from step a) to the new message (AssignBody or AssignStyledBody).
h) Send the message (SendMessage) or put it in your OutBox (SaveMessage)
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 1 guest

cron