February 11, 20169 yr I am having trouble with a custom message body for each recipient. The below script is only using the content of Email::body from the first record. any ideas? I would like to have a concatenated body field: Email::body = "Dear" & Email::first_name & "..... the rest of the message". when doing a test email with 3 family members in my foundset. again, the loop only sets the body of the first record. // First connect to the SMTP server and create the message. Set Variable [ $msgCreate = EmailConnectSMTP( "mail.example.com" ) and EmailCreate( Email::from ; Email::to ; Email::subject ) and EmailSetBody( GetAsCSS( Email::body ); "html" ) ] Go To Record/Request [ First ] Loop Set Variable [ $setRecipients = EmailRecipients [ Email::to ] ] Set Variable [ $msgSend = EmailSend ] Go To Record/Request [ Next ; Exit After Last ] End Loop // We've sent the same message to all recipients. Now disconnect Set Variable [ $disconnect = EmailDisconnect ] thanks in advance for any advice! -Kevin Edited February 11, 20169 yr by drrehak
February 11, 20169 yr Hi Kevin, it looks like you need to bring the 'Set Variable [ $msgCreate etc ]' within the Loop. Once you have sent the message with the Set Variable [ $msgSend = EmailSend ] line, the message has gone. Each extra iteration through the loop will fail, since you no longer have a message ready to send. You need to create a new message for each recipient.
February 11, 20169 yr Hi Kevin, You do need to bring in your create into the loop. You can call send multiple times on the same create statement. However, the way you have it set up now each email will have the same body as the first record because you only call set body once so the body of the email will persist through each iteration. You can either bring in the EmailSetBody call into your loop or leave it how it is and then put placeholders for the values you want to replace into the actual email body and then use the function EmailBodySubstitute in the loop to substitute the values in.
Create an account or sign in to comment