Thank you so much for the answer, that worked with minor change: emailMessage.EmailParamHeaders.To.ToArray().ToList().ForEach(x => { if (x != null) m.To.Add(x); });
U
User 8677026
@User 8677026
Posts
-
How to remove null value from Lambda expression or Array -
How to remove null value from Lambda expression or ArrayHere is my code: //Line below shows an email msg obj with To segment being an array (could have null to x number of receipients/emails): emailMessage.EmailParamHeaders.To //Below is creation of mail message obj: MailMessage m = new MailMessage(); //Line blow is adding each To email address to the "m" object emailMessage.EmailParamHeaders.To.ToArray().ToList().ForEach(x => m.To.Add(x)); How can I only add the elements of the array "To" where value is not null? Thank you in advance.