Hi I create List method with many parameters required than later be called in another void method sendRenewalReminder
but I get this error
Error: Compile Error: Method does not exist or incorrect signature: void createEmailMessage(Id, List, Id, Id, String, Boolean, String, Boolean, String) from the type automatedCommunication at line 105 column 17
Can someone help me to understand how this works actually in apex?
public class automatedCommunication{
public List<OrgWideEmailAddress> orgWideMail = [SELECT Id FROM OrgWideEmailAddress];
//Template for ID
public EmailTemplate ExpiringContractID = [SELECT Id, Name, Description, Subject FROM EmailTemplate WHERE Name =: 'Contract renewal notice ID' LIMIT 1];
public EmailTemplate DueInvoiceID = [SELECT Id, Name, Description, Subject FROM EmailTemplate WHERE Name =: 'Invoice due reminders ID' LIMIT 1];
public Id emailtemplate;
public String templateDescription; // The template description will be assigned to the Task Subject of the task
public String templateSubject;
public Id invPDFattachmemt{get;set;}
public Attachment attach{get;set;}
public EmailTemplate template;
public List<Invoice__c> linv;
public String senderName = 'xxx';
public String defaultReplyEmailID = '[email protected]';
public String defaultReplyEmailPH = '[email protected]';
public String defaultReplyEmailMX = '[email protected]';
public String expiredConQuery ='SELECT Id, AccountId, Account.AccountManager__r.Email, Account.AccountManager__r.isActive, Account.Owner.Email, Account.Owner.isActive, Account.Contractsigneduntil__c, Account.Due_date_of_last_open_invoice__c FROM Contact WHERE Id in: licontact';
public List<Messaging.SingleEmailMessage> createEmailMessage(Id templateName, Id orgEmailAddress, Id targetObjectId, Id whatId, Id accountManagerEmail, boolean accountManagerStatus, Id accountOwnerEmail, boolean accountOwnerStatus, String country ){
String ReplyToEmail;
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateId(templateName);
mail.setOrgWideEmailAddressId(orgEmailAddress);
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);
mails.add(mail);
return mails;
}
public void sendRenewalReminder(){
/**** Set Template ****/
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 != 'ID') {
template = DueInvoiceID;
}
emailtemplate = template.Id;
createEmailMessage(emailtemplate, orgWideMail, 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(createEmailMessage.mail);
}
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;
}
}
}
}