From 49305991425c970d6abcc017189bedf2a15a2846 Mon Sep 17 00:00:00 2001 From: Kipa24 Date: Fri, 28 Jun 2024 17:53:59 +0530 Subject: [PATCH] ALR-1707 --- src/main/default/classes/ScheduleSendEmail.cls | 8 +++++++- .../default/classes/ScheduledEmailTrigger.cls | 15 ++++++++++----- .../Task_Created_on_Account_Record.flow-meta.xml | 8 ++++---- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/main/default/classes/ScheduleSendEmail.cls b/src/main/default/classes/ScheduleSendEmail.cls index 74bb0df5..46c7197e 100644 --- a/src/main/default/classes/ScheduleSendEmail.cls +++ b/src/main/default/classes/ScheduleSendEmail.cls @@ -107,7 +107,13 @@ public with sharing class ScheduleSendEmail implements Schedulable { if (results[i].isSuccess()) { System.debug('Email sent successfully to ' + emailBatch[i].getToAddresses()[0]); } else { - + String errorMessage = results[i].getErrors()[0].getMessage(); + if (errorMessage.contains('EMAIL_ADDRESS_BOUNCED')) { + System.debug('Bounced email address: ' + emailBatch[i].getToAddresses()[0]); + } else { + System.debug('Failed to send email to ' + emailBatch[i].getToAddresses()[0] + + '. Error message: ' + errorMessage); + } } } } catch (Exception e) { diff --git a/src/main/default/classes/ScheduledEmailTrigger.cls b/src/main/default/classes/ScheduledEmailTrigger.cls index 6a2cd7af..7d8100b1 100644 --- a/src/main/default/classes/ScheduledEmailTrigger.cls +++ b/src/main/default/classes/ScheduledEmailTrigger.cls @@ -71,12 +71,12 @@ public with sharing class ScheduledEmailTrigger implements Schedulable { WHERE DisplayName = 'ALR Support Email' ]; - List contactRec =[Select Id,Email from Contact WHERE Id IN: contactIds ]; - + List contactRec = [SELECT Id, Email FROM Contact WHERE Id IN :contactIds]; + Integer batchSize = 100; List> emailBatches = new List>(); List emails = new List(); - for (Contact contact : contactRec){ + for (Contact contact : contactRec) { Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); email.setTemplateId(emailTemplate.Id); email.setOrgWideEmailAddressId(orgWideAddr.Id); @@ -102,7 +102,13 @@ public with sharing class ScheduledEmailTrigger implements Schedulable { if (results[i].isSuccess()) { System.debug('Email sent successfully to ' + emailBatch[i].getToAddresses()[0]); } else { - + String errorMessage = results[i].getErrors()[0].getMessage(); + if (errorMessage.contains('EMAIL_ADDRESS_BOUNCED')) { + System.debug('Bounced email address: ' + emailBatch[i].getToAddresses()[0]); + } else { + System.debug('Failed to send email to ' + emailBatch[i].getToAddresses()[0] + + '. Error message: ' + errorMessage); + } } } } catch (Exception e) { @@ -113,7 +119,6 @@ public with sharing class ScheduledEmailTrigger implements Schedulable { System.debug('Exception occurred in sendRenewalDueEmail method: ' + e.getMessage()); } } - public static EmailTemplate getEmailTemplate(String templateDevName) { EmailTemplate emailTemplateRec = null; List contactIdsList = new List(); diff --git a/src/main/default/flows/Task_Created_on_Account_Record.flow-meta.xml b/src/main/default/flows/Task_Created_on_Account_Record.flow-meta.xml index c3b8744b..1cf9a9a8 100644 --- a/src/main/default/flows/Task_Created_on_Account_Record.flow-meta.xml +++ b/src/main/default/flows/Task_Created_on_Account_Record.flow-meta.xml @@ -8,7 +8,7 @@ 252 Default Outcome - checksforMarch15 + checksforDec15 and Checks @@ -20,7 +20,7 @@ GroupDetails - + Default @@ -28,8 +28,8 @@ Checks Boolean AND( - MONTH(TODAY()) = 6, - DAY(TODAY()) = 23 + MONTH(TODAY()) = 12, + DAY(TODAY()) = 15 )