function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Soujanya_CG123Soujanya_CG123 

not able to add values to String array

Hi,

 

I am writing a trigger that will send emails. In this trigger i am adding email ids to an array as shown below

 

          emails.add('soujanya.bussa@capgemini.com');

 

emails is String array.

 

But i am getting an exception that "invalid to address" while trying to send out the email.

 

But if i am passing like emails = new String[]{'soujanya.bussa@capgemini.com'}; the emails are sent.

So please help me to solve this issue.

Message Edited by Soujanya_CG123 on 04-14-2009 11:26 PM
werewolfwerewolf
Try making emails a List<String> instead.  Then your add method will work.
Soujanya_CG123Soujanya_CG123

I can add list but i cant pass list as argument to Message.setToadress()

 

Actually it was not working because

   

        when i decalred array like this String[] emails = new String[4];   This array has 4 null values in it.

        and when i added a value emails.add(emailId); this value is asdded at 5th position.

 

What i did is after decalring the array i cleared it

                            String[] emails = new String[4];

                              emails.clear();

 and added the values to array and now it is working fine.

 

 

Thanks.

Message Edited by Soujanya_CG123 on 04-15-2009 09:01 PM