[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 - Fax printing

Fax printing

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Postby ente » Sat Nov 06, 2010 4:26 am

MarkB wrote:Oops. Sorry. Cut this bit:


Hello MarkB,
thankl you very much. I answer only today because not only the answerfunktion of the pocomail forung didn't work, but also the home page entrance was broken. Had to alarm Slaven first.

It's almost working... with my test contacts, the first address gets 1 attachment, the next two, then three, then four. Since I have to send about 200 invitations...
Could you have another look at it. I send you here the full new script, resp the old one with your adaptions:

Code: Select all
{### send_to_all_address_book
{ Script will send a prepared message to
{ all recipients listed in the chosen address book

{ Usage: use only manually, do not use on
{   Incoming or Outgoing mail

    { Initialize user settings: }
External $userdata1 "Address book name to send mail to (don't enter file extension):" "Zürichtest"
External $userdata2 "Enter subject of the message:" "Einladung"
External $userdata3 "What account would you like to send it from? %accounts%" "ABC"
External $userfile1 "Message Body..." nichtimmerleicht.pdf

Set $attachment "C:\Users\abca\AppData\Roaming\Pocomail\Templates\\nichtimmerleicht.pdf"

FileExists &flag $attachment
If &flag Then AttachmentExists
Set $t ""
AddStrings $t "The PocoScript " $PocoScriptName " can't find the file\n" $attachment
MessageBox $t
Exit
:AttachmentExists

    { Read address book into the variable: }
Set $path $addresspath
AddStrings $path $userdata1                           
AddStrings $path ".ini"
OpenBody $addresses $path

    { Open the template to be sent: }
OpenBody $template $userfile1

    { Set the upper boundary for search through addresses: }
LineCount #count $addresses
Dec #count
    { Set initial value of the counter }
set #i 0

    { Start the loop to collect all addresses into $ToSend }
:Loop
GetLine $a #i $addresses
    { Single record: First, Last and Addresses are loaded into a multiline var: }
ReadCSV $entry $a
LineCount #lines $entry
if #lines < 3 then Next
    { Addresses (could be more than one) are loaded into a new multiline var: }
GetLine $q 2 $entry
ReadCSV $set $q
AppendBody $ToSend $set

:Next
Inc #i
if #i > #Count then Leave
goto Loop

:Leave

LineCount #c2 $ToSend
Dec #c2
    { Set initial value of the counter: }
set #i 0

    { Setup the outgoing message: }
SetAccount $userdata3
CreateMessage %m
SetHeader %m "X-Account:" $userdata3
AppendToFile true
ReadEmail $e
SetHeader %m "From:" $e

    { Start the loop to send messages to all $ToSend addresses: }
:Loop2
GetLine $a1 #i $ToSend
AddTo %m $a1
AssignBody %m $template
SetHeader %m "Subject:" $userdata2
{  The next script line added 2010-11
AttachFile %m $attachment
SaveMessage %m "out.mbx"
ClearTo %m

Inc #i
if #i > #c2 then Out
goto Loop2

:Out
Exit
ente
Resident Poster
 
Posts: 182
Joined: Mon Sep 27, 2004 7:17 am
Location: Zurich, Switzerland

Postby MarkB » Sat Nov 06, 2010 5:15 am

I am going blind, obviously. Please cut these two new lines
Code: Select all
{  The next script line added 2010-11
AttachFile %m $attachment

and re-insert them after these:
Code: Select all
    { Setup the outgoing message: }
SetAccount $userdata3
CreateMessage %m
SetHeader %m "X-Account:" $userdata3
AppendToFile true
ReadEmail $e
SetHeader %m "From:" $e

The result will look like this:
Code: Select all
    { Setup the outgoing message: }
SetAccount $userdata3
CreateMessage %m
SetHeader %m "X-Account:" $userdata3
AppendToFile true
ReadEmail $e
SetHeader %m "From:" $e
{  The next script line added 2010-11
AttachFile %m $attachment
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby MarkB » Sun Nov 07, 2010 1:19 am

It's Sunday morning and I'm looking over your script.

Code: Select all
External $userfile1 "Message Body..." nichtimmerleicht.pdf

(a) $userfile1 is supposed to be the message body. nichtimmerleicht.pdf is not the message body; it is the attachment.
(b) Use quotation marks around the file name.
(c) Use the full file spec. For example: External $userfile1 "Message Body..." "C:\Users\abca\AppData\Roaming\Pocomail\Templates\sendallbody.txt"

With those corrections, and the one in the preceding post, your script appears to work. There's no harm in adding more troubleshooting, however. Since $userfile1 needs to be a full file spec, you could insert this code below the attachment check:
Code: Select all
FileExists &flag $userfile1
If &flag Then BodyFileExists
Set $t ""
AddStrings $t "The PocoScript " $PocoScriptName " can't find the file\n" $userfile1
MessageBox $t
Exit
:BodyFileExists


And stick in another check, for the address book file, as shown here:
Code: Select all
    { Read address book into the variable: }
Set $path $addresspath
AddStrings $path $userdata1                           
AddStrings $path ".ini"
{--- Test added 2010-11 ----------------
FileExists &flag $path
If &flag Then PathExists
Set $t ""
AddStrings $t "The PocoScript " $PocoScriptName " can't find the file\n" $path
MessageBox $t
Exit
:PathExists
{---------------------------------------
OpenBody $addresses $path
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby ente » Sun Nov 07, 2010 6:34 am

With those corrections, and the one in the preceding post, your script appears to work.


MarkB,

thank you very much! I did it and it worked - with my 6 privat addresses, for the test. Tomorrow the real thing will go out into the world (of Zurich only...)
Have a nice Sunday evening,
ente
ente
Resident Poster
 
Posts: 182
Joined: Mon Sep 27, 2004 7:17 am
Location: Zurich, Switzerland

Previous

Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 0 guests

cron