[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 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 - Send Mail to All in This Address Book

Send Mail to All in This Address Book

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Send Mail to All in This Address Book

Postby cssutton » Fri Aug 27, 2004 2:00 am

I am totally incompetent when it comes to dealing with scripts.

So I have no idea how to resolve my problem.

I can run this script with no problems so long as my address book does not have an entry in the "display as" box .

I would like to be able to use this script with the receipient's full name in the "display as" box .

When attempting to use the "display as" box, the script copies the address as john doe <john doe> and drops the real adress jdoe@xyz.com.

Can someone give me a "script for dummies" instruction as to how to resolve this?

I am using 3.1.0.1880 and the latest version of the script
cssutton
Drop-in Visitor
 
Posts: 9
Joined: Fri Aug 27, 2004 1:45 am

Postby Michael » Fri Aug 27, 2004 2:04 am

Are you using the "send_to_all_address_book2" script I modified (the one that is listed in the extras area)? It has fixes for Poco 3. I'm not sure if it is the one being delivered with Poco.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Send Mail to All in This Address Book

Postby cssutton » Fri Aug 27, 2004 3:24 am

es, I am.

And to verify that I have not screwed it up in some manner, I sent
back to the web site, copied the script again after receiving your
question, deleted the contents of the script, pasted this morning's
copy, saved it and ran it again.

Does the same thing....John Doe <john doe>

jdoe@xyz.com is not copied to the address line.

CSSJR
cssutton
Drop-in Visitor
 
Posts: 9
Joined: Fri Aug 27, 2004 1:45 am

Send Mail to All in This Address Book

Postby cssutton » Fri Aug 27, 2004 7:36 am

Well, I said at the begging that I am hopless when it involves script.

I deleted my original script and copied again from the web page to be sure that there was not some hidden code causing the addresses to not be copied correctly.

That is all I did.

Now when I click the "set up script" button, the "Message Body" button is dead.

So now the script will run, but it is not possible to change the message.

CSSJR
cssutton
Drop-in Visitor
 
Posts: 9
Joined: Fri Aug 27, 2004 1:45 am

Postby Michael » Fri Aug 27, 2004 3:29 pm

The line that triggers the "Message Body" button is
Code: Select all
External $userfile1 "Message Body..." sendallbody.txt


Please check that this line is intact. It should be immediately before
Code: Select all
ImportSettings
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Postby cssutton » Fri Aug 27, 2004 4:26 pm

External $userfile1 "Message Body..." sendallbody.txt
ImportSettings

{ Read address book into the variable: }

Set $path $addresspath
AddStrings $path $userdata1

The above is a copy of the code in my script.

I downloaded it again with no change.

I downloaded it with Firefox and again with IE to see if one of them was failing to pick up an essential.

No difference.

CSSJR
cssutton
Drop-in Visitor
 
Posts: 9
Joined: Fri Aug 27, 2004 1:45 am

Postby cssutton » Sat Aug 28, 2004 2:02 am

OK, I resolved the problem with the script not allowing me to change the message.

I went into the POCO directory and found an .ini that carried the name of one of the previous scripts for this same purpose. Moving that .ini to a folder unknown to POCO solved that problem.

However, I still can not get an email addressed properly if I have anything in the "display as" panel.

If most of the names in that address book do not have anything in the "display as" and there is only one, it may work occasionally. But try it with 20 or so all with the a name in the "display as" and you will get only two or so to work.

CSSJR
cssutton
Drop-in Visitor
 
Posts: 9
Joined: Fri Aug 27, 2004 1:45 am

Postby Hogyt » Sat Aug 28, 2004 3:37 am

Can you see if this works?

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

{ Modifications:
{ 13Oct2003 - M.Motek
{           - Format delivery address to include display name from address book (if present)
{           - Allow common variable tag usage in the message.
{           - Display list of address books in setup screen.
{           - Add ImportSettings command.

    { Initialize user settings: }

External $userdata1 "Address book name to send mail to (don't enter file extension):%addressbooks%" "Test"
External $userdata2 "Enter subject of the message:" "Announcement"
External $userdata3 "What account would you like to send it from? %accounts%" "jdf"
External $userfile1 "Message Body..." sendallbody.txt
ImportSettings

    { 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 $name 1 $entry
GetLine $email 2 $entry
Set $to $email
If $name = "" Then Append
Set $to $name
AddStrings $to " <" $email ">"
:Append
AppendBody $ToSend $to
: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
Set $Body $Template
ReplaceCVT $Body %m False
AssignBody %m $Body
SetHeader %m "Subject:" $userdata2
SaveMessage %m "out.mbx"
ClearTo %m
Inc #i
if #i > #c2 then Out

goto Loop2

:Out
Exit


I must admit i removed a part of the original code which i couldn't follow so perhaps this won't always work but it seemed ok when i tested it.
Mat
Hogyt
Poco Enthusiast
 
Posts: 241
Joined: Thu Jul 29, 2004 11:22 am
Location: England

Postby cssutton » Sat Aug 28, 2004 5:32 am

This seems to work.

I ran it on one address book that had 56 addresses, each with their full name in the display box and it copied every one of them correctly.

I don't recall all scripts having this requirement, but when setting this script up, I had to do the same thing that I did earlier today, that is go into the POCO folder and remove the .ini from the previous version.

In addition to that, it would not run until I ran it one time in debug and then saved it.

After that, it would allow me to change addresses, subjects and messages.

for some reason, each new version goes after the previous version .ini even though it saved is ouwn .ini.

It works and I am happy; not complaining. But the next time someone has a problem, get them to look at the .ini situation, run debug and then save.

CSSJR
cssutton
Drop-in Visitor
 
Posts: 9
Joined: Fri Aug 27, 2004 1:45 am

Postby cssutton » Sat Aug 28, 2004 12:36 pm

Now if you would write just one more script.....

One that would call up "Send to all in this Address Book", open it at the "set up script" page, allow us to enter our information, address book, subject, sender address; click on the message body button and write out our message....

At that point, it should have a save button which would save the new message and all of the other changes and exit.

I have a "send to all" button on my tool bar, so all I would need to do is click it and the job would be done.

CSSJR
cssutton
Drop-in Visitor
 
Posts: 9
Joined: Fri Aug 27, 2004 1:45 am

Postby Hogyt » Sun Aug 29, 2004 1:54 am

I don't think what you want is possible but instead you can have the script produce an input box that asks you the information you want to send, instead of filling it in on the setup script screen.

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

{ Modifications:
{ 13Oct2003 - M.Motek
{           - Format delivery address to include display name from address book (if present)
{           - Allow common variable tag usage in the message.
{           - Display list of address books in setup screen.
{           - Add ImportSettings command.
{ 29Aug2004 - M.Bowen (Hogyt)
{           - Fixed problem with "Display As" setting in address book
{           - InputBoxes ask for info instead of setting it in Setup Script
{ 14Sep2004 - Modified to work with address books where name is full path
{ 21Sep2004 - Improved error checking for empty address books

Set $OnErrorGoTo generalerror

    { Edit the following line to point to your text editor: }

External $userdata4 "Path to notepad.exe" "c:\\windows\\notepad.exe"
ImportSettings

    { Make sure file exists: }

FileExists &check $userdata4
If &check Then filefound
Set $message "Cannot find the text editor "
AddStrings $message $userdata4
MessageBox $message
Exit

:filefound
InputBox $userdata1 "Address book name to send mail to (don't enter file extension):%addressbooks%" "Test"
InputBox $userdata2 "Enter subject of the message:" "Announcement"
InputBox $userdata3 "What account would you like to send it from? %accounts%" "jdf"
Set $userfile1 $ScriptPath
AddStrings $userfile1 "sendallbody.txt"
Set $params \"
AddStrings $params $userfile1 \"
ExecuteAndWait $userdata4 $params
FileSize #n $userfile1
If #n ! 0 Then continue
MessageBox "No message body entered so sending mail has been cancelled"
Goto out

:continue

    { Read address book into the variable: }

Set $path $userdata1

If ":" ^ $userdata1 Then createdpath
Set $path $addresspath
AddStrings $path $userdata1

:createdpath
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
If #count < 1 Then emptyaddressbook
Dec #count

    { Set initial value of the counter: }

set #i 0

    { Start the loop to collect all addresses into $ToSend: }
Set $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 $name 1 $entry

GetLine $email 2 $entry
Set $to $email
If $to = "" Then Next
If $name = "" Then Append
Set $to $name
AddStrings $to " <" $email ">"
:Append
AppendBody $ToSend $to
:Next
Inc #i
if #i > #Count then Leave
goto Loop

:Leave
LineCount #c2 $ToSend
If #c2 < 1 Then emptyaddressbook2
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
Set $Body $Template
ReplaceCVT $Body %m False
AssignBody %m $Body
{AssignStyledBody %m $Body
SetHeader %m "Subject:" $userdata2
SaveMessage %m "out.mbx"
ClearTo %m
Inc #i
if #i > #c2 then Out

goto Loop2

:Out
Exit

:emptyaddressbook
  Set $message "The chosen address book "
  AddStrings $message \" $userdata1 \" " is empty"
  MessageBox $message
Exit

:emptyaddressbook2
  Set $message "The chosen address book "
  AddStrings $message \" $userdata1 \" " contains no email addresses"
  MessageBox $message
Exit

    { Error handler
:generalerror
  Set $message "An error has occurred in "
  AddStrings $message $PocoScriptName "\n$ErrorResult: " $ErrorResult "\n$ErrorLine: " $ErrorLine
  MessageBox $message
Exit


You may need to change the path to notepad.exe in setup script. At each stage of the script you can cancel the send. When editing the message in notepad, the only way to cancel it is to delete everything (so the file is empty) and save that, then the script will cancel for you.

I hope that makes sense and (almost) does what you want. If it's of no use then sorry!

Edit: Improved error checking
Last edited by Hogyt on Tue Sep 21, 2004 4:40 am, edited 1 time in total.
Mat
Hogyt
Poco Enthusiast
 
Posts: 241
Joined: Thu Jul 29, 2004 11:22 am
Location: England

Postby cssutton » Sun Aug 29, 2004 8:29 am

MT:

I have to tell you that is really neat.

Thank you.

CSSJR
cssutton
Drop-in Visitor
 
Posts: 9
Joined: Fri Aug 27, 2004 1:45 am

Postby cssutton » Mon Aug 30, 2004 3:03 pm

Mat:

Please accept my apology.

That was meant to be "Mat", not "MT".

CSSJR
cssutton
Drop-in Visitor
 
Posts: 9
Joined: Fri Aug 27, 2004 1:45 am

Postby Hogyt » Mon Aug 30, 2004 3:03 pm

hehe thats ok! I'm glad the script works for you :D
Mat
Hogyt
Poco Enthusiast
 
Posts: 241
Joined: Thu Jul 29, 2004 11:22 am
Location: England

Postby sokoyu » Tue Sep 21, 2004 4:03 am

Hi Folks,

I'm having trouble with the same script. I keep getting the message:

variable not previously defined $ToSend.

Any thoughts or wisdom would be gratefully received.

Thanks
sokoyu
Drop-in Visitor
 
Posts: 11
Joined: Tue Aug 31, 2004 8:18 am

Next

Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 1 guest

cron