Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you send a list on email

Status
Not open for further replies.

Serated

MIS
Aug 17, 2009
10
0
0
NZ
Hi There,

I am using a foreach loop, how can I use the items to send in one email instead of send an email for each item?

Regards.
 
Since you ask that general, assume you have this (pseudo code):

[pre]foreach(item in items) sendmail(item);[/pre]

If you don't want to send a mail per item, then the simple solution is not to do it in the loop, but after the loop.

[pre]foreach(item in items) addtomailbody(item);
sendmail(mailbody);[/pre]

So you have to define a variable for the mailbody, in which you add line for line, paragraph for paragraph, and finally just send this whole text once.

If you have such a problem with simple program flow, you shouldn't do programming. Seriously.

Bye, Olaf.
 
Thanks olaf,

I got this right and had to do some other tricks as I am building it into an html format email. Thanks for the help.

Thanks a mil.

Ser
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top