[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 - Using the send_to_all_address_book script

Using the send_to_all_address_book script

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Using the send_to_all_address_book script

Postby marcbelanger » Fri Dec 31, 2010 11:29 am

Hello,

I want to use the send_to_all_address_book script that is found in the Extras area. It allows for the sending of individual emails to all the addresses in a particular address book.

I have created an address book and entered the addresses I want to send to.

But then I'm stuck. The instructions are to "apply the script" but I don't know how to do that. The procedure seems to be different than applying scripts to all outgoing mail (as I do with a number of scripts).

So. . .

1: Can anybody point me in the right direction?

2: The script is marked as created for ver 3. Does that mean it will not work in version 4?

3. If this script does not work, can anybody suggest another solution?

Any help would be appreciated.

Marc
marcbelanger
Drop-in Visitor
 
Posts: 7
Joined: Sun Sep 13, 2009 3:58 am

Postby MarkB » Sat Jan 01, 2011 1:14 am

At the top of the script, optionally, specify handy default values in the "Initialize user settings" section. The file name is required and may have to be a fully-qualified path+name.

Code: Select all
    { Initialize user settings: }
External $userdata1 "Address book name to send mail to (don't enter file extension):" "Test"
External $userdata2 "Enter subject of the message:" "note to self"
External $userdata3 "What account would you like to send it from? %accounts%" "Main"
External $userfile1 "Message Body..." "C:\Users\Mark\AppData\Roaming\Pocomail\Templates\sendallbody.txt"


To send a message:

1. Compose your message body and save it as a .txt file. This is the file referenced in "Initialize user settings."

2. Set up the script: Go to Tools | Scripts. Select the script. On the Setup Script tab, fill out the form.

3. Run the script.

I advise experimenting with a test address book.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby MarkB » Sat Jan 01, 2011 1:31 am

Better:

1. Set up the script as follows: Go to Tools | Scripts. Select the script. On the Setup Script tab, fill out the form. Click the "Message body" link to open the text file in Notepad, compose your message, and save it.

2. Run the script.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Emails not being sent.

Postby marcbelanger » Sat Jan 01, 2011 4:56 am

Hi Mark,

Thank you very much for the quick reply. Much appreciated. And happy New Year!

Things didn't work out. Here's what I did

1. I created an address book called Communicators and entered three contacts
2. I went to Tools / Script
3. Selected the script
4. In the Setup Script tab area I filled out the form (Calling for the Communicators address book)
5. Clicked on "Message Body", which opened Notepad, and then created/saved a message:
C:\Users\Marc\AppData\Roaming\Pocomail\Mail\sendbodyall.txt
6. I then clicked on the tab Run on Selected Messages

Nothing happened. No emails were put into the SENT box. None were received.

Am I doing something wrong? Is it possible the script does not work for ver 4.8?



Marc
marcbelanger
Drop-in Visitor
 
Posts: 7
Joined: Sun Sep 13, 2009 3:58 am

Postby MarkB » Sat Jan 01, 2011 9:23 am

Marc, please insert the following script fragment immediately after the External commands. Then run the script and report what it tells you. This is temporary, for diagnostic purposes only.

Code: Select all
{    Checking
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
{
FileSize #n $userfile1
If #n > 0 Then GoodBody
MessageBox "Empty body template"
Exit
:GoodBody
{
SetAccount $userdata3
ReadAccount $t
If $t = $userdata3 Then AccountExists
Set $t ""
AddStrings $t "Error in the PocoScript " $PocoScriptName ":\nInvalid account name or faulty account data"
MessageBox $t
Exit
:AccountExists
{
Set $path $addresspath
AddStrings $path $userdata1
AddStrings $path ".ini"
FileExists &flag $path
If &flag Then PathExists
Set $t ""
AddStrings $t "The PocoScript " $PocoScriptName " can't find the address book\n" $path
MessageBox $t
Exit
:PathExists
{
If $userdata2 ! "" Then GoodSubject
MessageBox "Blank subject header"
Exit
:GoodSubject
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Looping problem?

Postby marcbelanger » Sat Jan 01, 2011 9:59 am

Hi,

I pasted the code as you instructed.

The three messages from my address book (of three contacts) was put in the OUT box.

I clicked on Send Queued Messages

The 3 messages were sent.

And then the batch of 3 messages continued to be sent.

When the count of sent messages reached 150 I clicked out of the programme to stop the process.

So...a "no end to the looping" problem?

Marc
marcbelanger
Drop-in Visitor
 
Posts: 7
Joined: Sun Sep 13, 2009 3:58 am

Revised script

Postby marcbelanger » Sat Jan 01, 2011 10:01 am

Here is the script revised after I followed your instructions (Or at least thought I did)

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):" "address"
External $userdata2 "Enter subject of the message:" "Announcement"
External $userdata3 "What account would you like to send it from? %accounts%" "My Account"
External $userfile1 "Message Body..." sendallbody.txt
{    Checking
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
{
FileSize #n $userfile1
If #n > 0 Then GoodBody
MessageBox "Empty body template"
Exit
:GoodBody
{
SetAccount $userdata3
ReadAccount $t
If $t = $userdata3 Then AccountExists
Set $t ""
AddStrings $t "Error in the PocoScript " $PocoScriptName ":\nInvalid account name or faulty account data"
MessageBox $t
Exit
:AccountExists
{
Set $path $addresspath
AddStrings $path $userdata1
AddStrings $path ".ini"
FileExists &flag $path
If &flag Then PathExists
Set $t ""
AddStrings $t "The PocoScript " $PocoScriptName " can't find the address book\n" $path
MessageBox $t
Exit
:PathExists
{
If $userdata2 ! "" Then GoodSubject
MessageBox "Blank subject header"
Exit
:GoodSubject
    { 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
SaveMessage %m "out.mbx"
ClearTo %m

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

:Out
Exit
marcbelanger
Drop-in Visitor
 
Posts: 7
Joined: Sun Sep 13, 2009 3:58 am

Postby MarkB » Sat Jan 01, 2011 11:54 am

Very strange. You ran the script as shown and got no messages claiming that the script couldn't find a file? And those sent messages had a body? You can delete the lines I gave you now.

Other than that, your script appears to be performing well for me. No perpetual loops.

Scripts in PocoMail run once for each selected message. With 50 messages selected, it will run 50 times. Therefore, when you run the "send to all address book" script you must have at most one message selected. However, if that were your problem, the out box would fill immediately, not stutter as you describe. I fear that I will have to await inspiration on this one.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby marcbelanger » Sat Jan 01, 2011 12:27 pm

As you say: Very strange.

I did not get a message claiming the script could not find the file.
And yes, the messages had a body.

I deleted the lines you sent me and tried again.

I set up the form. And then clicked on Run on Selected Messages. Same thing.

You say: Scripts in PocoMail run once for each selected message. I am assuming that when I click on Run on Selected Messages that the messages refered to are the ones in my chosen address book. I don't have to "select" in any other way. Right?

Meanwhile, I got the same problem. The three messages were queued, I sent queued and LOTS of messages were sent.

Oh well. Thanks for taking the time. I appreciate it. Let me know if inspiration strikes someday.

My email address is: m.belanger@radiolabour.org

Take care,

Marc
marcbelanger
Drop-in Visitor
 
Posts: 7
Joined: Sun Sep 13, 2009 3:58 am

Postby MarkB » Sun Jan 02, 2011 2:26 am

I am assuming that when I click on Run on Selected Messages that the messages refered to are the ones in my chosen address book.]

A terminological matter: Address books contain addresses, not messages. Messages are in the In, Sent, Draft, etc., folders. And when you run this script, have at most one message selected.

I don't have to "select" in any other way. Right?

Right.

Some process must be running ad infinitum. Exactly how have you been stopping that process? The status bar in Poco's main window, at the bottom, tells what script is running, if any (it will say "Press ESC to abort script <script-name>.") What script is running? For testing purposes, place the following line at the top of your script to give a Proceed/Cancel option each time it runs. Does it run once or repeat endlessly?
Code: Select all
InputBox $t "This is the 'send to all address book' script"


For the sake of privacy and spam prevention, it's probably advisable for you to edit the preceding message and remove the email address.
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