I have List as a parameter of the method but get the error when saving the class
Error: Compile Error: Method does not exist or incorrect signature: void createEmailMessage(Id, OrgWideEmailAddress, Id, Id, String, Boolean, String, Boolean, String) from the type automatedCommunication at line 138 column 24
public List<OrgWideEmailAddress> orgWideMail = [SELECT Id FROM OrgWideEmailAddress]; public Messaging.SingleEmailMessage createEmailMessage(Id templateName, List<OrgWideEmailAddress> orgWideEmail, Id targetObjectId, Id whatId, String accountManagerEmail, boolean accountManagerStatus, String accountOwnerEmail, boolean accountOwnerStatus, String country ){ String ReplyToEmail; Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setTemplateId(templateName); mail.setOrgWideEmailAddressId(orgWideEmail[0]); mail.setTargetObjectId(targetObjectId); mail.setWhatId(whatId); IF(accountManagerEmail <> null && accountManagerStatus == TRUE) ReplyToEmail = accountManagerEmail; ELSE IF(accountOwnerEmail <> null && accountOwnerStatus == TRUE) ReplyToEmail = accountOwnerEmail; ELSE IF(country == 'ID') ReplyToEmail = defaultReplyEmailID; ELSE IF(country == 'PH') ReplyToEmail = defaultReplyEmailPH; ELSE ReplyToEmail = defaultReplyEmailMX; mail.setReplyTo(ReplyToEmail); return mail; } and call it in below method
public void sendRenewalReminder(){ /**** Set Template ****/ Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>(); Set<Id> ids = new Set<Id>(); /**** Set filters and conditions (recipients and criteria -> To:, When?, who?, why?) ****/ List<Contact> licontact = [SELECT Id FROM Contact WHERE ContactForContracts__c = TRUE // only contacts that are marked to receive contract info AND Email <> '' AND Account.ExcludeFromAutomatedSendouts__c = FALSE // Checkbox on account to exclude Account from sendouts AND Account.Contractsigneduntil__c =: system.today() + 35 AND (Account.AccountCountry__c = 'ID' OR Account.AccountCountry__c = 'PH' OR Account.AccountCountry__c = 'MX') AND Account.TypeOfCompany__c = 'Agent / Broker' AND (Account.LastRenewalNoticeDate__c <: system.today() OR Account.LastRenewalNoticeDate__c =: null)]; // avoids multiple sendouts in case the method is called several times on the same day system.debug('aaa' + licontact.size()); /**** Start process ****/ IF(licontact.size() >0){ /**** Set parameters ****/ List<Contact> contacts = new List<Contact>(); contacts = Database.query(expiredConQuery); FOR(Contact cont : contacts){ ids.add(cont.Account.Id); } List<Account> accounts = [SELECT LastRenewalNoticeDate__c FROM Account WHERE Id in: ids]; /**** Create emails ****/ FOR(Contact cont : contacts){ if(cont.Account.AccountCountry__c == 'ID') { template = ExpiringContractID; } if(cont.Account.AccountCountry__c == 'MX') { template = ExpiringContractMX; } if(cont.Account.AccountCountry__c == 'PH'){ template = ExpiringContractPH; } emailtemplate = template.Id; mail = createEmailMessage(emailtemplate, orgWideMail[0], cont.Id, cont.AccountId, cont.Account.AccountManager__r.Email, cont.Account.AccountManager__r.isActive, cont.Account.Owner.Email, cont.Account.Owner.isActive, cont.Account.AccountCountry__c); mails.add(mail); if(Integer.valueof(Limits.getQueries()) >= 40){ break; } } system.debug(mails.size()); system.debug(mails); /**** Send emails ****/ IF(mails.size() >0){ Messaging.sendEmail(mails, false); /***** updates Account date of last sendout to avoid multiple sendouts ****/ FOR(Account acc : accounts){ acc.LastRenewalNoticeDate__c = system.today(); } update accounts; } } }