Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted (edited)

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 by drrehak
Posted

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.

Posted

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.

This topic is 3208 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.