Hi,
I am creating a new processing screen that will be used to send invoice reminders to customers, but I am not sure how to set up the send email button to do this correctly.
Below is an example of how I was trying to set it up. This code doesn’t publish because of some errors, so I know it’s completely wrong, but I am not sure how I can correct it.
public PXAction<DunningLettersDAC> sendEmail;
[PXUIField(DisplayName = "Send Email", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
protected IEnumerable SendEmail(PXAdapter adapter)
{
// Loop through all selected rows to process
foreach (DunningLettersDAC currentRecord in Base.ProcessingScreen.Cache.Updated)
{
var emailSettings = new SendMailSettings
{
Subject = "Your Email Subject",
Body = "Your Email Body",
AppendFiles = true
};
sendEmail.PressButton(adapter, emailSettings);
}
return adapter.Get();
}
Here is a list of what i am expecting this button to do, so let me know if there are some things on this list that on this list I won’t be able to achieve:
- Send email button should pull information from an existing email template
- To determine the email to send an email to, it should grab the Customer ID from the row currently being processed and pull the email from the customer card
- If possible, it should attach the relevant Customer Statement to the email, which I guess would be handled via the Email Template if it can be grabbed via the code for this new button.
What is the best way to trigger an email from from a custom button in a processing screen?
Let me know if you need any other information about what I am trying to do.
Kind regards,
Andrew