Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Resend Pending Emails After Editing
WhatsApp
Mahender Pal
4y
6.8k
0
2
100
Article
Introduction
Recently, we got one requirement to resend some pending emails after modification. In this article, I am going to share the solution steps.
Solution
Pending emails are read only so we can’t edit them. In case you want to perform any changes to these emails, you can use the following below steps.
Change Email stage to draft so that we can edit it.
Update Emails.
Send email using Code.
We are going to use workflow to perform the above actions, so first, we will be writing a custom workflow utility where we will be writing code to send email. If you are new to writing Custom workflow, you can refer to my old post
here
.
We need to use following code in our workflow assembly:
public
class
ResendPendingEmails: CodeActivity {
[RequiredArgument]
[Input(
"SourceEmail"
)]
[ReferenceTarget(
"email"
)]
public
InArgument < EntityReference > SourceEmail {
get;
set;
}
protected
override
void
Execute(CodeActivityContext executionContext) {
//Create the tracing service
ITracingService tracingService = executionContext.GetExtension < ITracingService > ();
//Create the context
IWorkflowContext context = executionContext.GetExtension < IWorkflowContext > ();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension < IOrganizationServiceFactory > ();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
EntityReference email = SourceEmail.Get(executionContext);
SendEmailRequest req =
new
SendEmailRequest();
req.EmailId = email.Id;
req.TrackingToken =
""
;
req.IssueSend =
true
;
SendEmailResponse res = (SendEmailResponse) service.Execute(req);
}
}
In the above code, we added one input parameter to our workflow assembly, which will take current email record as a parameter. We are just sending the emails using SendEmailRequest. Build your assembly and register it in your Dynamics 365 CE organization. Once our custom workflow assembly is registered in Dynamics 365 CE, we can use it in our workflow. Next, we need to create on demand workflow on the Email entity and use the following steps.
Step 1
First add a step to change the current email status to draft, like shown below:
Step 2
Add an Update step where we can edit our existing email. We want to change From lookup.
Step 3
The third step is where we need to use our custom workflow assembly and pass the current email record to our input parameter, as shown in the following:
Activate your workflow and run this on demand workflow on the pending email records. It will modify emails and will resend it.
So using the above methods, we can edit and resend pending emails.
I hope it will help someone!
Keep learning, Keep sharing!!
Dynamics 365 CE
Modify pending emails
Resend Pending Emails
Up Next
Ebook Download
View all
Printing in C# Made Easy
Read by 22.4k people
Download Now!
Learn
View all
HIMBAP
We are expert in Microsoft Power Platform.
Membership not found