Solved

convert arrayList to string

Posted on 2006-11-09
6
243 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-
  • 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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 

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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
2 questions 10 29
Cant save 3D 4 23
Create a WebAPI using a generic return parameter 9 31
Unable to connect C# program to an SQL database - Exception occurs. 4 49
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

830 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