Skip to content

Commit

Permalink
Merge pull request #616 from santhoshb-msft/sb-globalemail
Browse files Browse the repository at this point in the history
Send email address from the Email Template
  • Loading branch information
santhoshb-msft authored Feb 20, 2024
2 parents f1eb5bc + bdc02da commit d4b3286
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/Services/Helpers/EmailHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,15 @@ public EmailContentModel PrepareEmailContent(Guid subscriptionID, Guid planGuId,

var eventData = this.planEventsMappingRepository.GetPlanEvent(planGuId, subscriptionEvent.EventsId);

if (eventData != null)
{
toReceipents = eventData.SuccessStateEmails;
copyToCustomer = Convert.ToBoolean(eventData.CopyToCustomer);
}

if (string.IsNullOrEmpty(toReceipents))
{
throw new Exception(" Error while sending an email, please check the configuration. ");
}

//First add To, Cc, Bcc email addresses from email template
if (emailTemplateData != null)
{
if (!string.IsNullOrEmpty(toReceipents) && !string.IsNullOrEmpty(emailTemplateData.Cc))
if (!string.IsNullOrEmpty(emailTemplateData.ToRecipients))
{
toReceipents = emailTemplateData.ToRecipients;
}

if (!string.IsNullOrEmpty(emailTemplateData.Cc))
{
ccReceipents = emailTemplateData.Cc;
}
Expand All @@ -96,6 +91,22 @@ public EmailContentModel PrepareEmailContent(Guid subscriptionID, Guid planGuId,
subject = emailTemplateData.Subject;
}

//If the plan event data contains plan specific ToEmailAddress then override the above
if (eventData != null)
{
if (!string.IsNullOrEmpty(eventData.SuccessStateEmails))
{
toReceipents = eventData.SuccessStateEmails;
}

copyToCustomer = Convert.ToBoolean(eventData.CopyToCustomer);
}

if (string.IsNullOrEmpty(toReceipents))
{
throw new Exception(" Error while sending an email, please check the configuration. To email empty");
}

return FinalizeContentEmail(subject, body, ccReceipents, bccReceipents, toReceipents, copyToCustomer);

}
Expand Down

0 comments on commit d4b3286

Please sign in to comment.