[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 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 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 - Hello and how filter by addressbook

Hello and how filter by addressbook

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Hello and how filter by addressbook

Postby olaf_noehring » Thu Sep 30, 2004 7:45 pm

Hi all of you, special hi to Slaven and James (dada)

You might remember me, I was in the translation (to german) "crew"
Now, I have finally switched to Poco and there is a new question:

How can I filter incomming mail by using address books: If a user (mail sender / recipient) is in my addressbook "friends" I want to move that a special mailbox.

Olaf
--
emailaddress on my website
http://www.team-noehring.de
olaf_noehring
Drop-in Visitor
 
Posts: 6
Joined: Thu Sep 30, 2004 7:29 pm

Postby Pete » Fri Oct 01, 2004 5:04 am

I don't think that you can search only a single address book with a filter.
Pete
 

Postby Michael » Fri Oct 01, 2004 12:58 pm

The following script should do what you want. It also will put the message in a sub mailbox if you've created one beneath your "Friends" mailbox.

Code: Select all
{ Script Name   :   SaveByBook
{ Author        :   Michael Motek - www.jdfsoftware.com
{ Creation Date :   October 1, 2004
{ Version       :   1.05
{ Usage         :   Mode: Incoming, Outgoing, Post-Send or Selected
{ Description   :   Save messages from/to people whose addresses are in a
{                   specific address book to a specific mailbox (or sub
{                   mailbox).
{ Input         :   None
{ Notes         :   This script requires setup with the script setup function.

{
{ Revision History :
{ Date        Change ID       Developer
{             Description
{ ---------  ---------------  ----------------------------------------------
{ 02Oct2004  Version 1.01 - Add checking for multiple recipients with user defined action.
{ 02Oct2004  Version 1.02 - Added incoming and outgoing mailboxes.
{ 02Oct2004  Version 1.03 - Added "SuggestUsage" command.
{ 02Oct2004  Version 1.04 - Added action when no submailbox.
{ 02Oct2004  Version 1.05 - Fix bug in submailbox path.
{ --------------------------------------------------------------------------


External $AddressBook "Address book%addressbooks%" "Friends"
External $IncomingMailbox "Incoming message mailbox%Mailboxes%" "Friends"
External $OutgoingMailbox "Outgoing message mailbox%Mailboxes%" "Friends"
External $ActionWhenMultipleRecipients "Action when multiple recipients (none/save)" "None"
External $ActionWhenNoSubMailbox "Action when no sub mailbox (create/none/save)" "Save"

SuggestUsage 1 4

{  Check the mode to see whether we extract the From or To address.

If #PocoScriptMode = 1 Then Incoming
If #PocoScriptMode = 2 Then Outgoing
If #PocoScriptMode = 4 Then Outgoing
AddStrings $Msg "Wrong mode for the " $PocoScriptName " script"
MessageBox $Msg
Exit

:Incoming
ReadHeader $Address "From" %Message
Set $Mailbox $IncomingMailbox
GoTo ExtractAddress
:Outgoing
Set $Mailbox $OutgoingMailbox
ReadTo $Address %Message
LineCount #Addresses $Address
If #Addresses = 1 Then ExtractAddress
GetLine $Address 1 $Address
LowerCase $ActionWhenMultipleRecipients
If $ActionWhenMultipleRecipients ! "save" Then Done

{  Isolate the address
:ExtractAddress
ExtractEMail $Address

{  Check to see if the address is in the address book.
IsAddressPresent &Known $Address $AddressBook
Not &Known
If &Known Then Done

{  Get the name field for the person.
GetAddressField $Name $Address "name" $AddressBook

{  Check to see if that person has a specific sub mailbox.
AddStrings $Path $MailPath $Mailbox "/" $Name ".mbx"
FileExists &PersonalMailbox $Path
If &PersonalMailbox Then SetPersonalMailbox

{  Now we know there isn't a personal mailbox, what do we do?

LowerCase $ActionWhenNoSubMailbox
If $ActionWhenNoSubMailbox = "none" Then Done
If $ActionWhenNoSubMailbox = "save" Then Save

{  Action is neither "None" nor "Save" so we will create a sub-mailbox.

:SetPersonalMailbox
AddStrings $Mailbox \\ $Name

{  Save the message to the mailbox.
:Save
AppendToFile True
SaveMessage %Message $Mailbox
DeleteMessage %Message

:Done
Exit


Notes:
1. Setup is requried.
2. This script has not been tested, use at your own risk.
3. The script will also work on outgoing messages if you add it to either the "Post-Send" or "Outgoing" tab. I recommend the "Post-Send" tab.
4. Oct 2, 2004 - Script modified to handle multiple recipients in outgoing messages.
5. Oct 2, 2004 - Script modified to support different incoming/outgoing mailboxes.
6. Oct 2, 2004 - Add option for what action to take when there is no sub mailbox. Possible actions are:
  • Create - A new submailbox will be created using the name of the sender (from the address book)
  • None - Script will not save message (it will remain in the In box unless acted on by a subsequent filter or script),
  • Save - The message will be saved in the primary mailbox.
Last edited by Michael on Sat Oct 02, 2004 12:35 pm, edited 6 times in total.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Wow, Question

Postby olaf_noehring » Fri Oct 01, 2004 9:24 pm

Hi Michael,

that is great response. I was about to try it already but I have another question before:

When I setup the script I choose Addressbook and Mailbox.
Does this mean the mail is filtered by one addressbook (the chosen) only or can I set different addressbooks with different mailboxes.

Also: When I use it in the outgoing filter I suppose the mail will be put into the mailbox I defined, so that for example I define "friend1" goes in mailbox "FROM my friends" a mail sent to my "friend1" will also be put in that, instead of being put into the "TO my friends" mailbox?

What is my "Friends" mailbox (a self created?)


Why am I asking for a filter possibility like this? Of course because I know it from Eudora ... (sorry for the comparison)
Thanks Olaf
--
emailaddress on my website
http://www.team-noehring.de
olaf_noehring
Drop-in Visitor
 
Posts: 6
Joined: Thu Sep 30, 2004 7:29 pm

Postby Michael » Sat Oct 02, 2004 1:08 am

Script (above) modified to allow users control when there are multiple recipients. This change has not been tested, use at your own risk.
Last edited by Michael on Sat Oct 02, 2004 1:16 am, edited 1 time in total.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Re: Wow, Question

Postby Michael » Sat Oct 02, 2004 1:15 am

olaf_noehring wrote:Hi Michael,

that is great response. I was about to try it already but I have another question before:

When I setup the script I choose Addressbook and Mailbox.
Does this mean the mail is filtered by one addressbook (the chosen) only or can I set different addressbooks with different mailboxes.


The mail is filtered by one address book, you can create multiple copies of the script under different names and run it that way. The problem with extending the script to handle multiple address books is that there is no command within PocoScript to determine which address book(s) a person is in (this can be done but it takes a lot more code). If there were the script would also have to allow for a precedence to be established.

olaf_noehring wrote:Also: When I use it in the outgoing filter I suppose the mail will be put into the mailbox I defined, so that for example I define "friend1" goes in mailbox "FROM my friends" a mail sent to my "friend1" will also be put in that, instead of being put into the "TO my friends" mailbox?


That is correct, it would be quite simple to modify the script so that it either supported different incoming/outgoing mailboxes.

olaf_noehring wrote:What is my "Friends" mailbox (a self created?)


The command used in the configuration does not allow you to specify an mailbox that hasn't already been created. If you run the script without using the configuration then a "Friends" mailbox will be created if you don't already have one.

olaf_noehring wrote:Why am I asking for a filter possibility like this? Of course because I know it from Eudora ... (sorry for the comparison)
Thanks Olaf


No problems with comparisons, any software product will grow with competition and can learn from it's competitors.

PS: I am not an employee of Poco Systems Inc.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Postby Michael » Sat Oct 02, 2004 1:30 am

I have now modified the script to support different mailboxes for incoming and outgoing messages. Setup required, and as before, this has not been tested.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

will test

Postby olaf_noehring » Sat Oct 02, 2004 1:43 am

Hi Michael

I will test ASAP

take care & thanks again
Olaf
--
emailaddress on my website
http://www.team-noehring.de
olaf_noehring
Drop-in Visitor
 
Posts: 6
Joined: Thu Sep 30, 2004 7:29 pm

Postby Michael » Sat Oct 02, 2004 1:47 am

Another very slight change to assist in configuration. This change only affects the Setup screen. It adds two buttons to allow automatic configuration as an incoming and/or post-send script.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

you are fast

Postby olaf_noehring » Sat Oct 02, 2004 2:03 am

Hi Michael

you are fast - I have not even taken a look on the last version ;-)

Olaf
--
emailaddress on my website
http://www.team-noehring.de
olaf_noehring
Drop-in Visitor
 
Posts: 6
Joined: Thu Sep 30, 2004 7:29 pm

Postby Michael » Sat Oct 02, 2004 12:26 pm

Yet another mod (I needed this for my own use). The ability to configure the script action when no sub-mailbox exists. See notes under the script above. (As before, use at your own risk, I haven't tested these changes yet).
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Postby Michael » Sat Oct 02, 2004 12:36 pm

Updated to version 1.05 (found and fixed a bug - sub mailboxes would be created outside the master mailbox rather than inside it).
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Postby Pete » Tue Oct 05, 2004 8:05 am

(I moved this topic to the PocoScript forum -- Pete)
Pete
 


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 3 guests

cron