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

Need help
Hi guys first of all thanks to all the people here they always help alot!
i have tos end an email notification to multiple users and each user there will be multiple records related
so in the email to each user will be just like below:
user1 recieves email.....[30 records based on some criteria]
user2 recieves email.....[30 records]
i am able to fetch the records all i to do is sent email and for that i am not getting how i can put all the emails and related records to one email in MAP or LIST? please help me my code is below
List<GSQM_ESH_Audiometry__c> personsResponsible = new List<GSQM_ESH_Audiometry__c>();
Set<String> personIDSet = new Set<String>();
Set<String> audiometryIDSet = new Set<String>();
Map<String, String> personIDAudioID = new Map<String, String>();
global void execute(SchedulableContext sc) {
Map <Id,Id> audiometryObj = new Map<Id,Id>();
for(GSQM_ESH_Audiometry__c obj : [SELECT Id, Person_Responsible_for_Assessment__c FROM GSQM_ESH_Audiometry__c
WHERE Person_Responsible_for_Assessment__c!=null]){
audiometryObj.put(obj.Id, obj.Person_Responsible_for_Assessment__c);
personIDSet.add(obj.Person_Responsible_for_Assessment__c);
audiometryIDSet.add(obj.Id);
}
System.Debug(audiometryObj.keyset());
list<String> email = new list<String>();
Map<Id,String> usersObj = new Map<Id,String>();
for(user userObj: [SELECT Id,email from user where Id=:personIDSet]){
usersObj.put(userObj.Id,userObj.email);
email.add(userObj.email);
}
list<String> employeeName = new List<String>();
list<GSQM_ESH_Employee_for_Audiometry_Test__c> audiometryListObj = new list<GSQM_ESH_Employee_for_Audiometry_Test__c>();
Map<String, list<GSQM_ESH_Employee_for_Audiometry_Test__c>> audiometryTest= new Map<String, list<GSQM_ESH_Employee_for_Audiometry_Test__c>>();
for(GSQM_ESH_Employee_for_Audiometry_Test__c obj : [SELECT userID__c, Employee_Name__c, Audiometry__c FROM
GSQM_ESH_Employee_for_Audiometry_Test__c
WHERE Audiometry__c IN:audiometryObj.keyset()
and Employee_Name__c!=NULL and Next_test__c = Next_MONTH]){
if(obj!=NULL){
//i have to put this email1 and employee names related to one email in MAP or some list so then i can send email in bulk
System.Debug(obj.employee_Name__c);
String email1 =usersobj.get(obj.userID__c);
System.Debug(email1);
}
}