I have a custom workflow activity that when it runs it sends an email. There are three contact fields were the user can type in the email address in one or two or all three contact fields. The contact. I need to know how to still send an email if the first contact field contains an email address and the other two do not and /or how to still send the email if the first two contact fields have email address and the third one does not.
My email code: That works only when there is all three email address but does not when there is only one or to email address in the contact field.
//BUILD EMAIL #region Buid Email string htmlStringFirst = htmlString.ToString(); EntityReference orderSales = new EntityReference("salesorder", GTRI_OrderId); // Create the 'From:' activity party for the email ActivityParty fromParty = new ActivityParty { PartyId = new EntityReference(SystemUser.EntityLogicalName, Guid.Parse(IAMIdEmail)) }; // Create the 'To:' activity party for the email ActivityParty toParty1 = new ActivityParty(); toParty1.AddressUsed = ConfirmationContact1.Trim(); ActivityParty toParty2 = new ActivityParty(); if (toParty2.Contains("ConfirmationContact2") && ((string)toParty2["ConfirmationContact2"]) != null) { toParty2.AddressUsed = ConfirmationContact2.Trim(); } ActivityParty toParty3 = new ActivityParty(); if (toParty3.Contains("ConfirmationContact3") && ((string)toParty3["ConfirmationContact3"]) != null) { toParty3.AddressUsed = ConfirmationContact3.Trim(); } ActivityParty ccParty = new ActivityParty() { PartyId = new EntityReference(SystemUser.EntityLogicalName, Guid.Parse(IAMIdEmail)) }; #region Send First Email if (EmailType == "First_Email") { Email email = new Email { To = new ActivityParty[] { toParty1, toParty2, toParty3 }, From = new ActivityParty[] { fromParty }, Cc = new ActivityParty[] { ccParty }, Subject = "The Order has been placed for " + CustomerIdNameEmail, Description = htmlStringFirst, DirectionCode = true, RegardingObjectId = orderSales }; _emailId = service.Create(email); } // Use the SendEmail message to send an e-mail message. SendEmailRequest sendEmailreq = new SendEmailRequest { EmailId = _emailId, TrackingToken = "", IssueSend = true }; SendEmailResponse sendEmailresp = (SendEmailResponse)service.Execute(sendEmailreqPlease help....thank you
newjeep