[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 - Fusion of two scripts

Fusion of two scripts

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Fusion of two scripts

Postby ente » Wed Jun 15, 2011 1:41 am

Hello MarkB
many years ago you helped me with a script I had created using a script coming with pocomail for answering mail when absent. I use it together with a incoming filter for moving it afterwards into the specific folder:

External $userdata1 "Choose a character to quote message with:" ">"
External $userdata1 "Choose a character to quote message with:" ">"
External $userdata1 "Choose a character to quote message with:" ">"
{### Reply to Mail from ZVAB with Template
{----------
{v1.0 - 2002.02.11 - Roger Leemann / Götz Perll
{ Copy of "Reply with Template"
{----------
{ This script will reply to a message from a saved template
{ Usage: not suitable for automatic use; use only on demand.

{ Initialize user settings: }
External $userdata1 "Choose a character to quote message with:" ">"
External $userfile1 "Create body template" "Zvab_ErstbestellerVorausrechnungRpl.txt"

CreateMessage %m
ReadHeader $a Subject %message
AddStrings $subject "Bestätigung mit Voraus-Rechnung für die "
AddStrings $subject $a
SetHeader %m Subject $subject

OpenBody $Body $userfile1
ReadHeader $From From %message
AddTo %m $From

{ If template file exists load it }
FileExists &F $userfile1
if &F then UseBody

{ Otherwise, use a blank template }
Set $a "MESSAGE BODY TEMPLATE CURRENTLY NOT SET"
AppendBody $a " "
AppendBody $a " "
AppendBody $a "To use this script, please setup a default message body template:"
AppendBody $a " "
AppendBody $a " press F9 to open Filters and Scripts window, then click on Setup Script."
AppendBody $a " From the drop down box select script \"Reply with Template\"."
AppendBody $a " Click on the Create Body Template button to create a template."
AppendBody $a " When done, just click on File, Save."
goto Edit

:UseBody
set $a $Body

:Edit
ReadBody $b %message

{v1.0 delete certain lines with information that the adresseee shouldn't see

set #ll -1
LocateLine #ll "Diese Bestellung wurde vom ZVAB" $b
if #ll > -1 then DL1
goto FL2
:DL1
DeleteLine $b #ll 1

:FL2
set #l -1
LocateLine #ll "Zum Bearbeiten bzw. Reaktivieren dieser Bestellung" $b
if #ll > -1 then DL2
goto FL3
:DL2
DeleteLine $b #ll 2

:FL3
set #ll -1
LocateLine #ll "Die ZVAB-Mitgliedsnummer Ihres Antiquariats lautet" $b
if #ll > -1 then DL3
goto CONT
:DL3
DeleteLine $b #ll 1

:CONT
QuoteBody $b $UserData1
AppendBody $a " "
AppendBody $a $b
AssignBody %m $a
EditMessage %m
MarkMessage %message 8
:EXIT

This are the incoming filter settings:
bestellung@zvab.com,From,script,Bestellungsdruck,0,0,ABC,or,1,"Bestellung via Abebooks:",Subject,move,Korrespondenz\ABC\BestellEingang,0,0,or,0,"(via CGI)",Subject,print,"this message",0,0,or,0,"antiquariat.de-Bestellung vo",Subject,move,In,0,0,or,0,bestellung,Subject,move,In,0,0,,0,,,move,In,0,0,1,0

...and a few years ago you created for me a script which adds a BC address to every outgoing mail. It is run by a filter in outgoing.

Code:
AddBCC %message "goetz.perll@orange.fr"

This are the outgoing filter settings:
perll@abc-buch.ch,From,script,AddBC,0,0,,,1,,,move,Sicherheit\SicherheitAusgang,0,0,,0,,,move,In,0,0,,0,,,move,In,0,0,,0,,,move,In,0,0,,0,,,move,In,0,0,0,0


Only now I realised, that, when I use addBCC, the other script doesn't work anymore the way it ought to.
My question: Can I merge them into 1 script?
ente
Resident Poster
 
Posts: 182
Joined: Mon Sep 27, 2004 7:17 am
Location: Zurich, Switzerland

Re: Fusion of two scripts

Postby MarkB » Wed Jun 15, 2011 6:05 am

Hi, Götz. Nice to hear from you.

The incoming filter catches messages from best...@zvab.com and calls a script that creates automated replies to those messages. The outgoing filter catches all messages from per...@abc-buch.ch, to anyone, and calls a script to add a BCC address to them. Those two things appear to be compatible. What problem are you seeing?

If the only messages that need a BCC are automated replies to messages from bes...@zvab.com, then it would be a simple matter to put the AddBCC in the first script and eliminated the second script. For anything else, I'm afraid that I'm going to have to ask you to describe carefully what you want to accomplish.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Re: Fusion of two scripts

Postby ente » Thu Jun 16, 2011 12:06 am

MarkB wrote:Hi, Götz. Nice to hear from you.

The incoming filter catches messages from best...@zvab.com and calls a script that creates automated replies to those messages. The outgoing filter catches all messages from per...@abc-buch.ch, to anyone, and calls a script to add a BCC address to them. Those two things appear to be compatible. What problem are you seeing?

If the only messages that need a BCC are automated replies to messages from bes...@zvab.com, then it would be a simple matter to put the AddBCC in the first script and eliminated the second script. For anything else, I'm afraid that I'm going to have to ask you to describe carefully what you want to accomplish.


Hi Mark,
thank you for your fast reply. What I wish to acomplish is:
1) of every mail which leaves to office has one copy to go to sicherheit/sicherheitausgang
2) every mail which leaves to office (when I'm away) gets addressed also to goetz.perll@orange.fr

Prepairing my answer I realised that the "first" script I send was the wrong one
Here comes the right one:

{### Bestätigung Message
{ A bit more sophisticated, this script will reply to an
{ incoming mail, with a pre-saved template. For this
{ script to run unattended, make sure that in the program
{ settings (F7) under Miscellaneous, Send Queued Messages
{ When Checking Mail is checked.

{ Usage: best used on Incoming messages

{ Initialize user settings: }
External $userfile1 "Create message template" "Bestätigung.txt"
AppendToFile True
ReadHeader $Email "From:" %message
ReadHeader $Subject "Subject:" %message
Set $NewSubject "Re: "
AddStrings $NewSubject $Subject
set $mailbox neueingänge.mbx
Lowercase $Subject
if "bestellung von" ^ $Subject then foundvalue
goto leave
:foundvalue
if "über test" ^ $Subject then foundvalue2
goto leave
:foundvalue2
:Anfrage
if "Anfrage" ^ $Subject then foundvalue3
goto leave
:foundvalue3
if "Online-Suchauftrag" ^ $Subject then foundvalue4
goto leave
:foundvalue4

CreateMessage %Out
ReadEmail $From
SetHeader %Out "From:" $From
Set $Name $Email
ExtractEmail $Email
SetHeader %Out "To:" $Email
Set $NewSubject "Re: "
AddStrings $NewSubject $Subject
SetHeader %Out "Subject:" $NewSubject

OpenBody $NewBody $UserFile1
ReadBody $OldBody %message
QuoteBody $OldBody
AppendBody $NewBody " "
AppendBody $NewBody $OldBody
AssignBody %Out $NewBody

SaveMessage %Out "e:\temp3.txt"
SaveMessage %Out "Neueingänge.mbx"

:Leave
{ Done }

This is the filter using that script:
perll@abc-buch.ch,From,script,"Bestätigung ",0,0,,and,1,Bestellung,Subject,move,Korrespondenz\ABC\Bestätigungen,0,0,,1,,,copy,Sicherheit\SicherheitAusgang,0,0,,0,,,move,In,0,0,,0,,,move,In,0,0,,0,,,move,In,0,0,1,0

The problem I had was that the command "move" in the addBC overruns the move command in the first script. That meens I don't get a copy of the mail in Korrespondenz\ABC\Bestätigungen and there is even no copy of the mail in the send folder! The latest I find very strange! Since that has happened before (no copy of the mail in send) I had created the folder Sicherheit/SicherheitAusgang and Sicherheit/SicherheitEingang - in the first I have a copy of every outgoing mail and in the second I have a copy of every incoming mail
Sincerely, Ente
ente
Resident Poster
 
Posts: 182
Joined: Mon Sep 27, 2004 7:17 am
Location: Zurich, Switzerland

Re: Fusion of two scripts

Postby MarkB » Thu Jun 16, 2011 1:44 am

2) every mail which leaves to office (when I'm away) gets addressed also to goetz.perll@orange.fr


Assuming that "every mail which leaves to office (when I'm away)" means all, and only, messages created by the auto-reply script "Bestätigung Message" in the preceding post, do this:
Remove the line
Code: Select all
AddBCC %message "goetz.perll@orange.fr"
from the script called by the outgoing filter. Insert a similar line into the CreateMessage section of the "Bestätigung Message" script, as follows:
Code: Select all
CreateMessage %Out
ReadEmail $From
SetHeader %Out "From:" $From
Set $Name $Email
ExtractEmail $Email
SetHeader %Out "To:" $Email
Set $NewSubject "Re: "
AddStrings $NewSubject $Subject
SetHeader %Out "Subject:" $NewSubject
AddBCC %Out "goetz.perll@orange.fr"


Notice that "%message" has changed to "%Out" here. Is my assumption correct?

-----------------------------------------------------------------

The auto-reply script currently is not actually sending the reply; it is merely saving the message in the Neueingänge (New releases?) mailbox. To send, you must either use a SendMessage command or save the message to the Out box (if Poco is configured to send messages in the Out box immediately).

Edit: The original Vacation Message script saves the reply message to the Out box and assumes that Poco is configured to send queued messages when checking mail.

-----------------------------------------------------------------

1) of every mail which leaves to office has one copy to go to sicherheit/sicherheitausgang


That should be unproblematic. Notice, however, that your filter appears to be moving, not copying, the messages. Try changing move to copy.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Re: Fusion of two scripts

Postby MarkB » Fri Jun 17, 2011 12:58 am

BCC:
An AddBCC line can be inserted in any script before the SaveMessage line.

The Auto-reply:
In the script above, a line like
SaveMessage %Out "Out.mbx" [or whatever your Out folder is named]
will cause the message to be sent and copied to the Sent folder (or whatever your Sent folder is named), provided (a) the option "Send queued messages when checking mail" is enabled, and (b) Poco is configured to automatically copy sent messages to the Sent folder.

Copying the Auto-reply Message:
My current understanding is that you wanted messages copied only because the auto-reply script was not working properly. If so, you can now disable the copying in your filters and scripts.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Re: Fusion of two scripts

Postby MarkB » Sun Jun 19, 2011 1:50 am

Your auto-reply script is capable, of course, of saving a copy of the reply message in Korrespondenz\ABC\Bestätigungen. One objection to doing so is that the presence of the message in that folder signifies that it has been sent, but in fact it has not been sent. Rather, it is queued in the Out box waiting to be sent. Best practice is to do things in their logical order -- which here would be to have a filter copy messages while they are actually in transit. This FILTER should not conflict in any way with the auto-reply SCRIPT which ran minutes earlier.

The auto-reply script has been accumulating messages in a plain-text archive called temp3.txt.

Re. Poco's failure to copy to Sent:
I do recall one circumstance in which messages properly queued in the Out box and sent are not copied to the Sent folder. It occurs after a script (AutoZip) modifies the message in the Out box, using the approved DeleteMessage-SaveMessage routine. But this kind of failure is rare in my experience.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 1 guest

cron