Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALR-1707 #923

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main/default/classes/ScheduleSendEmail.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
15 changes: 10 additions & 5 deletions src/main/default/classes/ScheduledEmailTrigger.cls
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ public with sharing class ScheduledEmailTrigger implements Schedulable {
WHERE DisplayName = 'ALR Support Email'
];

List<Contact> contactRec =[Select Id,Email from Contact WHERE Id IN: contactIds ];
List<Contact> contactRec = [SELECT Id, Email FROM Contact WHERE Id IN :contactIds];

Integer batchSize = 100;
List<List<Messaging.SingleEmailMessage>> emailBatches = new List<List<Messaging.SingleEmailMessage>>();
List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
for (Contact contact : contactRec){
for (Contact contact : contactRec) {
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setTemplateId(emailTemplate.Id);
email.setOrgWideEmailAddressId(orgWideAddr.Id);
Expand All @@ -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) {
Expand All @@ -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<Id> contactIdsList = new List<Id>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<locationY>252</locationY>
<defaultConnectorLabel>Default Outcome</defaultConnectorLabel>
<rules>
<name>checksforMarch15</name>
<name>checksforDec15</name>
<conditionLogic>and</conditionLogic>
<conditions>
<leftValueReference>Checks</leftValueReference>
Expand All @@ -20,16 +20,16 @@
<connector>
<targetReference>GroupDetails</targetReference>
</connector>
<label>checks for March15</label>
<label>checks for Dec 15</label>
</rules>
</decisions>
<environments>Default</environments>
<formulas>
<name>Checks</name>
<dataType>Boolean</dataType>
<expression>AND(
MONTH(TODAY()) = 6,
DAY(TODAY()) = 23
MONTH(TODAY()) = 12,
DAY(TODAY()) = 15
)</expression>
</formulas>
<formulas>
Expand Down