Getemailaddresses with selectsql

Hi all,

 

In the to Property of SendMail activity I'd like to get emailaddress for a list of users assigned to a specific role...

something like:

 

GetEmailAddresses(SelectSql(null,"select eusername from eassignment where erolename in ('myrole')").List)

 

I've double checked and all users in that role have a valid email, but I get always:

 

"(CLOB) Exception 'The specified string is not in the form required for an e-mail address.' occurred when attempting to 'Run script'.
The specified string is not in the form required for an e-mail address."

 

What's wrong?

 

Thanks in adv.

 

Andrea

 

Tagged:

Comments

  • What is the result you are getting when you retrieve the list into a memo or text field by using a button script instead of using the SendMail acitvity.

     

    GetEmailAddresses(SelectSql(null,"select eusername from eassignment where erolename in ('myrole')").List)

     

    Does this all look OK?

     

     

     

  • Hi Andrea

     

    GetEmailAddresses returns a List but SendEmail requires the email addresses to be a semi colon separated string.

     

    This should convert the List to a string for you:

     

    string.Join(";",Mstm.GetEmailAddresses(SelectSql(null,"select eusername from eassignment where erolename in ('myrole')").List).Select(o=>o.ToString()).ToArray())
    

     

    Hope that helps

     

    iain

  • Hi Iain,

    thanks for the explanation.

     

    Unfortunately in the statement there is an error, I tried to make some change with no success, can you help me?

     

    error.png

  • Hi Andrea

     

    I can't see the attachment in your reply above... can you repost it?

     

    What version are you running? (The above example is working ok for me in 9.1.1).

     

    An alternative to the above is the following:

     

    string.Join(";",Array.ConvertAll<object, string>(Mstm.GetEmailAddresses(SelectSql(null,"select eusername from eassignment where erolename in ('myrole')").List), Convert.ToString))
    

     

    Thanks

     

    Iain

  •  

    Great! This works fine!

     

    The error was

    ) expected ; expected Invalid expression term ',' ; expected ; expected invalid expression term ')' ; expected Invalid expression

     

    We're running on 9.1.2

     

    Many Thanks

    Andrea