[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 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 - Move incoming mail to a folder based on Group

Move incoming mail to a folder based on Group

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Move incoming mail to a folder based on Group

Postby dlbayne » Sun Apr 24, 2011 4:29 pm

Is rthere a way to move incoming mail to a folder based on the Group to which the contact is assigned?
dlbayne
Drop-in Visitor
 
Posts: 5
Joined: Sun Jul 06, 2008 12:40 am
Location: Cypress, CA

Re: Move incoming mail to a folder based on Group

Postby MarkB » Mon Apr 25, 2011 4:13 am

You can filter incoming mail. The hitch is that a filter by itself, as far as I know, cannot recognize group membership. So the filter has to call a script. If you want to go that route...

First, save the following script. Name it MoveToSomewhere.poc, perhaps.

Initialize the two variables at the top of the script. In $target_mailbox, include parent mailboxes. For example, for a subfolder called Ultra inside the subfolder Urgent inside the inbox, set $target_mailbox to "In\Urgent\Ultra.mbx".

If the group name is not unique, that is, if groups with the same name exist in more than one address book, you will have to specify a particular address book (e.g., "Work" in place of "*") in the line GroupList $list $senderaddress "*".

Second, create a filter to trigger the script. Go to Tools | Filters | Incoming | Add Script.

Code: Select all
Set $group_name "Enemies"
Set $target_mailbox "Keep.mbx"

ReadHeader $senderaddress "From:" %message
ExtractEmail $senderaddress
GroupList $list $senderaddress "*"
LinePos #index $group_name $list
If #index < 0 Then Done
Set $t $mailpath
AddStrings $t $target_mailbox
FileExists &found $t
If &found Then MoveMessage
MessageBox "Can't find target mailbox"
Exit
:MoveMessage
DeleteMessage %message
SaveMessage %message $target_mailbox
:Done
Exit


Notice: Moderators might move this topic to the scripts section.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Re: Move incoming mail to a folder based on Group

Postby dlbayne » Mon Apr 25, 2011 5:58 pm

Does this script move the email into online folders? I am using IMAP. (I think this is way over my head. I should probably keep things simple.)
dlbayne
Drop-in Visitor
 
Posts: 5
Joined: Sun Jul 06, 2008 12:40 am
Location: Cypress, CA

Re: Move incoming mail to a folder based on Group

Postby MarkB » Mon Apr 25, 2011 11:47 pm

dlbayne wrote:Does this script move the email into online folders? I am using IMAP.

No, probably not. And I can't help you with IMAP. Sorry.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Re: Move incoming mail to a folder based on Group

Postby dlbayne » Tue Apr 26, 2011 3:27 am

Thank you so much for your replies. I should have been more clear in my first query that I was attempting to accomplish the task using IMAP. Since I am working at different locations during the week, I would be using Webmail offsite and Pocomail at my home office; thus the reason for IMAP. Using Webmail filters I am able to automatically move mail based on email addresses to folders online, but not based on groups. I will be satisfied with with that. Thanks again.
Don
dlbayne
Drop-in Visitor
 
Posts: 5
Joined: Sun Jul 06, 2008 12:40 am
Location: Cypress, CA


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 2 guests

cron