You need to sign in to do that
Don't have an account?
Error on page 113 of the Winter '10 Visualforce Developer's Guide
I'm not sure to whom I should report this, but there appears to be an error in the example code on page 113 of the Winter '10 Visualforce Developer's Guide. The code covers an example for sending emails from a Visualforce page. The part where the error lies is here:
String addresses;if (account.Contacts != null){addresses = account.Contacts[0].Email;// There may be more contacts, so loop through the whole listfor (Integer i = 1; i < account.Contacts.size(); i++){if (account.Contacts[i].Email != null){addresses += ':' + addresses;}}}
I copied this code straight from the pdf and my test app wouldn't send out multiple emails if there were multiple recipients. I found the error and it works now, and thus I can only assume the documentation is in error.
The error lies in the last line before all the '}'s. it reads -- address += ':' + address; -- but it should read -- address += ':' + account.Contacts[0].Email;
I made this change and my test code works fine now.
Hi Jim,
Thanks for pointing this out. I write documentation for Visualforce.
Actually, the correct replacement is
addresses += ':' + account.Contacts[i].Email;
Though I've rewritten several lines, to appear like this:
String addresses; if (account.Contacts[0].Email != null) { addresses = account.Contacts[0].Email; } // Loop through the whole list of contacts and their emails for (Integer i = 1; i < account.Contacts.size(); i++) { { if (account.Contacts[i].Email != null) { addresses += ':' + account.Contacts[i].Email; } } } String[] toAddresses = addresses.split(':', 0);
All Answers
Hi Jim,
Thanks for pointing this out. I write documentation for Visualforce.
Actually, the correct replacement is
addresses += ':' + account.Contacts[i].Email;
Though I've rewritten several lines, to appear like this:
String addresses; if (account.Contacts[0].Email != null) { addresses = account.Contacts[0].Email; } // Loop through the whole list of contacts and their emails for (Integer i = 1; i < account.Contacts.size(); i++) { { if (account.Contacts[i].Email != null) { addresses += ':' + account.Contacts[i].Email; } } } String[] toAddresses = addresses.split(':', 0);
oops, right, [i], not [0]. I copied from the wrong part.
Ok, as long as you guys know.