c# - Send a list of users by email in MVC4 -


I am trying to send a list of users by email. I'm working properly, however My list includes 2 users, only one user is shown when the email is received.

This way I am filling out my list, it works fine.

  list & lt; AccountCourse & gt; AC = new administrative () GetAccountCourseByCourseId (crs.Id); Var ListOfUsers = New List & lt; String & gt; (); Foreach (Accountcars Acer in ATC) {String Username = New Admin} GetAccountByAccountId (acrs.AccountId); ListOfUsers.Add (username); }  

And likewise, I am trying to fill the body of the e-mail message with the list of users. This is exactly what is not working properly:

 for  (int i = 0; i  

Any ideas how can I fix this? Thank you.

Try this code instead:

  msg.Body = " Registered users for this course are: "+ string .joined (", ", listoffusor.ORARA) +" ";  

String.Join will take names of your users and add them using commas and spaces. Give you a single string for your body; Your solution is changing the body every time through the loop, resulting in your email body being the last name in the list only.


Comments

Popular posts from this blog

c++ - C/pp Sockets, recv()/send() works only under gdb -

GO: Serve static pages -

objective c - How to open front/back camera at the same time in iOS developing? -