Link to home
Start Free TrialLog in
Avatar of -Dman100-
-Dman100-Flag for United States of America

asked on

convert arrayList to string

I need to convert an arrayList to a string so I can pass the parameter into my method that requires a string parameter:

ArrayList repEmailList = RepresentationDAO.GetEmailList(anAddress.StateAbr);
//foreach (string emailAddress in repEmailList)

SendMail.Send(repEmailList, "info@compasslearning.com", "CompassLearning Sales Information Request", strmsg);

repEmailList needs to be converted to a string

Thanks for any help.
Avatar of Expert1701
Expert1701

Do you want to send one email to all the recipients?

  string addresses = "";
  foreach(string emailAddress in repEmailList)
    addresses += (emailAddress=="" ? "" : ";") + emailAddress;

  SendMail.Send(addresses, ...
Avatar of -Dman100-

ASKER

yes, I'm only sending one email to all recpients.
And I made a mistake in my code, it should have been:

  string addresses = "";
  foreach(string emailAddress in repEmailList)
    addresses += (addresses=="" ? "" : ";") + emailAddress;

  SendMail.Send(addresses...

But that should do it!
If I may ask, what is this line doing:  addresses += (emailAddress=="" ? "" : ";") + emailAddress;
ASKER CERTIFIED SOLUTION
Avatar of Expert1701
Expert1701

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your help!  It works great!

Regards,
-D-