First you need to change Array mailToArray =
to string[] mailToArray
.
mailmessage.To.Add(mailToArray
(i));
should then be mailmessage.To.Add(mailToArray
[i]);
, the indexer for arrays. ()
next to an identifier are used to imply a method, while []
are used to 'index into' an array and grab a specific element. Though is a normal operator and be overridden, so theoretically it could even be treated as a method (don't do this.)