Forum Discussion
christopher_gillis
8 years agoCommunity Manager
Hello,
The issue you are running in to is that the to_email_users variable is defined only within the context of your for loop. It is not accessible outside of the for loop which is causing the error that you are seeing.
One solution would be to move the definition of the to_email_users variable to just before the loop, but this would cause another issue which is that you are overwriting the variable each time you run through the loop. This means that only the last user in the list would actually be sent the email.
I have updated the sample that you provided to add the recipients one-by-one directly to the MailMessage. However, please be aware that this sample is untested as I don't have the full context of this Method. While this code compiled on my end, there may be some issue that I was unable to find through testing.
Chris
_____________________________
Christopher Gillis
Aras Labs Software Engineer