Solved

convert arrayList to string

Posted on 2006-11-09
6
246 Views
Last Modified: 2010-04-16
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.
0
Comment
Question by:-Dman100-
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 11

Expert Comment

by:Expert1701
ID: 17907953
Do you want to send one email to all the recipients?

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

  SendMail.Send(addresses, ...
0
 

Author Comment

by:-Dman100-
ID: 17908041
yes, I'm only sending one email to all recpients.
0
 
LVL 11

Expert Comment

by:Expert1701
ID: 17908063
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!
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:-Dman100-
ID: 17908066
If I may ask, what is this line doing:  addresses += (emailAddress=="" ? "" : ";") + emailAddress;
0
 
LVL 11

Accepted Solution

by:
Expert1701 earned 500 total points
ID: 17908201
the correct one is,

  addresses += (addresses=="" ? "" : ";") + emailAddress;

It checks to see if this is the first email address and if not, includes a semicolon before adding it.  It is so you do not have an extra ';' either at the start or the end of your string.
0
 

Author Comment

by:-Dman100-
ID: 17908498
Thanks for your help!  It works great!

Regards,
-D-
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question