Jump to content

loop script to limit addresses in BCC field


julesw

This topic is 7153 days old. Please don't post here. Open a new topic instead.

Recommended Posts

hi all,

i am very new to using filemaker to email, so please bear with me.

i understand how to create a script that will generate an email with the right addresses in the BCC field.

but we have been advised that spam detectors may block messages sent to over a certain number of addresses. (don't worry, we don't want to send spam!)

i want to create a script that has a loop in it that can keep track of the number of email addresses, sends an email when it gets to the first, say 100 addresses, then go back into the loop at the next record and keeps going till it gets to the next 100. obviously it must then know to extract only the second 100 addresses, not include the first 100 as well. this is the bit that i dont have a clue how to do.

[note: each record has 3 email address fields, which may or may not be filled in, so the record number will not correspond to the count of email addresses field]

any suggestions most appreciated!

Link to comment
Share on other sites

The solution given below is based on your note that every record can have 3 email addresses which may or may not be filled in and if all the three addresses are present then there will be total three address in the bcc field.

Declare a global variable gBccEmailCount(To hold the count upto 100, return type would be number), and gBccEmailAddresses (return type would be text).

Try the script below.

gBccEmailCount=0

gBccEmailAddresses=""

go to record/request [first]

loop

if (trim(field1:emailaddress)<>"")

if trim(gBccEmailAddresses)="" then

gBccEmailAddresses = gBccEmailAddresses

else

gBccEmailAddresses = gBccEmailAddresses & ";" & field1:emailaddress

endif

gBccEmailCount = gBccEmailCount + 1

perform script("Checking BccCount and Sending Mail");

end if

if (trim(field2:emailaddress)<>"")

if trim(gBccEmailAddresses)="" then

gBccEmailAddresses = gBccEmailAddresses

else

gBccEmailAddresses = gBccEmailAddresses & ";" & field2:emailaddress

endif

gBccEmailCount = gBccEmailCount + 1

perform script("Checking BccCount and Sending Mail");

end if

if (trim(field3:emailaddress)<>"")

if trim(gBccEmailAddresses)="" then

gBccEmailAddresses = gBccEmailAddresses

else

gBccEmailAddresses = gBccEmailAddresses & ";" & field3:emailaddress

endif

gBccEmailCount = gBccEmailCount + 1

perform script("Checking BccCount and Sending Mail");

end if

go to record/request[Exit after last, next]

End Loop

/////////////end of the first script///////////////////////////

Checking BccCount and Sending Mail Script:

if gBccEmailCount = 99 (since we are starting from zero)

send Mail("Please see filemaker pro help on how to use the send mail script step")

set Field("gBccEmailCount","0")

set Field("gBccEmailAddresses","")

end if

////////////end of the second script////////////////////

Let me know if the above logic works file for you.

Thanks,

--Sanjay

Link to comment
Share on other sites

thanks sanjay!

i think i understand how it works. could you (or anyone else who gets it) clarify exactly what you mean by "Declare a global variable gBccEmailCount(To hold the count upto 100, return type would be number), and gBccEmailAddresses (return type would be text)."

i had created a field that kept a running total of the email addresses count, but i don't think this is what you mean.

if it is just a global field, i haven't really used these before so don't know much about them... do i just create it and then leave it blank?

Link to comment
Share on other sites

okay, i think i understand the stuff about the global fields. i just create a global number field for the email count, and a global text field for the email addresses, and leave them blank. its the script that fills them in...

so far so good.

i cant work out how to enter in the first bit of the script:

gBccEmailCount=0

gBccEmailAddresses=""

scriptmaker has a list of commands on the left, which one do i use... there is one called 'insert calculated result' - is this the way to do it?

Link to comment
Share on other sites

okay, thanks. am giving it a go.

one thing im noticing, for every 'if' i get a 'end if' - more than were in the script you listed. just wondering where they should all go? straight after the 'if'? or would it be okay to have a whole lot of 'end if's at the end of the script??

Link to comment
Share on other sites

okay, ignore the above, i realised i could delete the 'end if's if need be.

i replicated the script you described. just tried it with a found set that contained 133 email addresses.

it produced one message with only 2 addresses in the BCC field, not separated with a ';' or anything else, and then froze. as in, i cant do anything in either filemaker or my mail program (outlook) - it's just showing the hourglass. think ill have to end task.

any thoughts?

Link to comment
Share on other sites

sorry, im obviously posting prematurely... ignore the above message too! that was just a problem with the send mail script, which ive corrected.

HOWEVER, it created one message with all 133 email addresses in the BCC field.

ie, it seems to have failed to do the main thing i wanted it to...

Link to comment
Share on other sites

here i go again, in my one person dialogue...

actually it wasnt all 133 email addresses, it was all the addresses in the 'email 1' address field. there were 124 of these, so it should have triggered a second message, as well as then going on to generate messages for the email 2 and email 3 fields.

if this is any help, i tried removing the

setField(gBccEmailCount,0)

setField(gBccEmailAddresses,"")

from the beginning of the script, and the result was that it created a message for the email 2 field only.

Link to comment
Share on other sites

You may have to add another field to the table: set number. Each record will be given a particular set number. All records with the same set number will be selected for one email batch. Sure, this is low-tech, but at least it will work. You could write a script to fill this field in, incrementing the number as necessary.

Link to comment
Share on other sites

Hi Jules,

Yesterday, I received your email in my personal mail account. I replied it and today when I say the mail was bounced back. Sorry for that. Could you please send me both the scripts which you have written. Let me have a look on it so that I can find the exact solution.

Please also check if there is nothing wrong with the if's and endif's.

Thanks,

--Sanjay

Link to comment
Share on other sites

hi sanjay

thanks for your help. i attach a clone of the file.

the script based on yours is called Email script. it includes commands to perform the scripts Checking BccCount and Sending Mail 1,2&3 (one for each email address field).

i then had a go breaking the script up into smaller scripts - see email master, which references Email script copy 1,2&3 (which in turn reference the checking bcc and sending mail ones mentioned above).

these ones are a disaster, they just loop endlessly.

if you can help i will be eternally grateful!

EVcontactsClone1.zip

Link to comment
Share on other sites

Hi Jule,

I am sorry but I was not able to unzip your attachment after downloading. I use winzip and it is not allowing to open and unzip it. Could you please send it as an attachment in a private message. I am sorry to inform you so late but since friday I have not been able to use my login here. Then I created a new one and I am replying using the new login id. I have sent the question to the support also. I tried emailing to you about me not being able to open your attachment but then the email bounced back saying that I have to login into the forum to send an email. Let me know and I will try to reply asap.

If you could also send the script in a text file, I can have a look on it.

Thanks,

--Sanjay

Link to comment
Share on other sites

This topic is 7153 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.