Skip to content

Validate EmailAddress1 on "To" recipients in SendEmailRequestHandler#313

Merged
JonasGLund99 merged 4 commits intomasterfrom
copilot/validate-email-address-in-send-email-request-handl
Mar 2, 2026
Merged

Validate EmailAddress1 on "To" recipients in SendEmailRequestHandler#313
JonasGLund99 merged 4 commits intomasterfrom
copilot/validate-email-address-in-send-email-request-handl

Conversation

Copy link
Contributor

Copilot AI commented Mar 2, 2026

When sending an email, resolved (partyid-based) recipients in "To" must have an emailaddress1 — without this check, emails could be dispatched to entities with no email address.

Changes

  • SendEmailRequestHandler: After confirming a partyid recipient exists in the DB, adds a check that the referenced entity has a non-empty emailaddress1. Throws FaultException if missing.
  • TestSendEmail: Adds TestSendEmailRequestFailsWhenRecipientHasNoEmailAddress1 — creates a contact without EMailAddress1 and asserts the send request throws.
var partyEntity = db.GetEntityOrNull(partyRef);
if (partyEntity is null)
    throw new FaultException($"{partyRef.LogicalName} with Id = {partyRef.Id} does not exist");

if (string.IsNullOrEmpty(partyEntity.GetAttributeValue<string>("emailaddress1")))
    throw new FaultException($"{partyRef.LogicalName} with Id = {partyRef.Id} does not have an email address");
Original prompt

This section details on the original issue you should resolve

<issue_title>Validate To in SendEmailRequestHandler</issue_title>
<issue_description>All references in "To" should have an "EmailAddress1"</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: magesoe <8904582+magesoe@users.noreply.github.com>
Copilot AI changed the title [WIP] Validate 'To' field for EmailAddress1 in SendEmailRequestHandler Validate EmailAddress1 on "To" recipients in SendEmailRequestHandler Mar 2, 2026
@JonasGLund99 JonasGLund99 marked this pull request as ready for review March 2, 2026 08:14
@JonasGLund99 JonasGLund99 merged commit ae6d4b0 into master Mar 2, 2026
2 checks passed
@JonasGLund99 JonasGLund99 deleted the copilot/validate-email-address-in-send-email-request-handl branch March 2, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate To in SendEmailRequestHandler

3 participants