Solved

convert arrayList to string

Posted on 2006-11-09
6
240 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Email Body 4 46
What does this  TN Map<T, TN>(T src) mean? 5 32
Duplicate a row 2 33
Why don't I see this table in EDMX file? 2 20
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now