You need to sign in to do that
Don't have an account?

Messaging.sendMail: multiple different emails in a single call?
Hello. On p. 420 of the 2008 Force.com Developers Guide (distributed at Dreamforce 2008), it says that "Message.sendMail method takes an array of messages to send, so you can send multiple messages in one single call."
Does this mean I can send an array of different email messages, each to a single recipient, in one call? What is the syntax for constructing the array? The documentation is not clear.
Here are the specifics of my situation: I need to send an email containing a personalized URL to several people, and I can't use merge fields/templates because the people's data are stored in a custom object, not in the Contact object.
Thanks
David
you create a list for email messages. Then you create your emails, one by one (maybe in a loop) and add them to that list. Finally you do a Messaging.sendEmail(yourList).
Pseudo Code
I agree that the documentation is not easy to understand, becuase the examples only create one single message, and then create the list (with this one single email as the only item) on the fly in the Messaging.sendEmail() call
from the Apex Guide:
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_classes_email_outbound.htm
All Answers
In the api docs there are examples of sendMail() in Jave and c# that might help shed some light on the usage. They do mention sending mass emails with the function and it seems like the examples can be easily scaled.
Hope that helps.
you create a list for email messages. Then you create your emails, one by one (maybe in a loop) and add them to that list. Finally you do a Messaging.sendEmail(yourList).
Pseudo Code
I agree that the documentation is not easy to understand, becuase the examples only create one single message, and then create the list (with this one single email as the only item) on the fly in the Messaging.sendEmail() call
from the Apex Guide:
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_classes_email_outbound.htm
Thanks for your reply. After I posted this I did some further reading and came to understand the syntax of the new [sObject] {} statement and realized what you said, that I need to create a separate list and use that.
David
Can you still only send 10 emails at a time this way inside the list? What is the maximum number of distinct emails that can be sent at once through Salesforce?
More to the point, if I needed to send many more emails, how would I be able to accomplish this?
check out the Mass Email Method of the Apex Email Class:
http://www.salesforce.com/us/developer/docs/apexcode/index.htm
Good question DTCF - I've started another thread to get clarification on the 10 maximum.
Here is the thread I posted on the maximum number. Does that have the info you need?
http://boards.developerforce.com/t5/Apex-Code-Development/Messaging-SingleEmailMessage-array-and-sendEmail-limits/m-p/185839