0
  Set<ID> objIDs = new Set<ID>(); //objIDs is used to store the user Id's

i have two id in ObjIDs,

for example: 0054E000001jEoUQAU, 0054E000001lC07QAE.

How to query the email address from ObjIDs and assign it List<String> ?

2

For querying from the set of Id, use below SOQL

SELECT Fields from API_Name_of_Object WHERE Id IN: objIDs;

Using a for loop, then you can fetch the Email Address and then add it to List

1

As your Id's are related to user object and you want the email field so you can simply do this

Set<string> emailSet = new Set<string>();
for(user U : Select email from user where Id IN: objIDs)
       emailSet.add(u.email);
0

You can get idea from the following piece of code, get iteration using for loop and get each user's email through iterated users and assign to your List<string>.

List<string> UserEmail = new List<string>();

for(User u : [select Id, Email from User where Id =: objIDs]){
    UserEmail.add(u.Email);
}

Hope it helps you out !!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.