I have a very simple construct, where I’m trying to send the same document individually to multiple recipients. So, I have a multivalue field with valid names, and a small @For loop that goes through the elements in that field, assigns the values one by one to SendTo, and then does @MailSend.
But it doesn’t work. With an @Prompt, I can see that the logic is good, it loops OK, but as soon as I add @MailSend into the loop, it stops looping!
Here’s the code (rs is a multivalue field):
@For(n := 1;
n <= @Elements(rs);
n := n + 1;
FIELD SendTo:=rs[n];
@Prompt([Ok]; rs[n]; SendTo);
@Command([ViewRefreshFields]);
@MailSend
)
Everything runs & looks good if the @MailSend is commented out. The SendTo field updates on each loop.
Subject: Can @MailSend be used inside a loop?
A couple of possibilities:
Firstly, this might be worth checking out:
If the user’s notes.ini file includes the statement
NoExternalApps=1
then any formula involving @MailSend is disabled. The user doesn’t see an error message; the formula fails to execute.
Secondly, you’ve only created one document. If I remember correctly, @MailSend saves the current document, which takes it out of read mode.
There are a number of potential solutions to this.
-
Try putting the document into edit mode before each MailSend
-
You may need to do an @Compose in there before each loop.
-
Try using @MailSend with parameters (ie specify the sendto etc in the parameters.)
These are all just suggestions - see which one works for you.
Stephen Lister
Subject: RE: Can @MailSend be used inside a loop?
Thanks Stephen.
-
There’s no blocker in my notes.ini, as I know both from checking and because I can send a “normal” MailSend outside of a loop.
-
I’ll try this and report back
-
I’m specifically trying NOT to use @MailSend with parameters, becuae it’s a primitive construct, with very limited ability to format the outgoing message - it comes out in Courier, no highlighting or colors etc.
Any other thoughts gratefully received.