I'd like to create a popup list on one of my Visualforce pages, for a user to select from a list of OrgWideEmailAddress
records. My goal is to limit the list to only those records that they're allowed to use. I'm going to save the selection for use in later automatic emails.
Based on what I've read, I won't be able to send emails to certain OrgWideEmailAddresses:
- The address hasn't been verified yet. I don't see any fields in the schema that appear to show verification state.
- The address is only available to profiles that the user isn't a member of. I don't see where the profile list is stored for each record.
Some of my problem could just be due to not understanding the standard objects so well, and perhaps there's a way to get at this through UserInfo
, or by making my query on the User
object which may have a child relationship to OrgWideEmailAddress
since it's listed in the schema viewer of the Force.com IDE.
Here's the test code I'm working with:
for (OrgWideEmailAddress addr : [SELECT DisplayName, Address
FROM OrgWideEmailAddress ORDER BY DisplayName]) {
System.debug( addr.DisplayName + ' <' + addr.Address + '>');
}
I tried creating a new Messaging.SingleEmailMessage
and then calling setOrgWideEmailAddressId()
on it with each OrgWideEmailAddress
Id, in hopes that invalid Ids would throw an exception, but to no avail.
My goal is to modify the test code to provide just the subset of records that the current user will be able to use.