Plugins for incoming and outgoing emails in CRM 2011 - dynamics-crm-2011

I need to create two plugins for CRM 2011
Whenever an email is incomging or outgoing I need to check if the email has any attachments in it. If yes I need to set one boolean value to true.
When user (user only, not workflow or automatic message etc.) answers some email I need to fire a plugin that checks incident's status (email is regarding to an incident) and depending on the status do some things.
I'm not really familiar with this whole email tracking concept. We have an email router configured, but that's all I can say.
What are the steps that I need to use in order to achieve plugins described?
For the first plugin I think "Create of email" is enough, right? What about the second plugin and how can I make sure that plugin is fired only when a real person sends an email?

For the first plugin:
To check for attachments for an email you will need to create a plugin which executes on create of the ActivityMimeAttachment entity, which is the entity which stores email attachments.
When an inbound email is processed by the Email Router (or tracked in the Outlook Client) the parent Email record is created first, and then an ActivityMimeAttachment record is created for each attachment.
If you try to check for attachments when an Email is created it will be executing before any attachments are created. However, you may also need a plugin to execute when an Email is created to set the 'Has Attachments' field to false.
The plugin on ActivityMimeAttachment will need to get the parent email activity and set the 'Has Attachments' field to true. This will handle both inbound and outbound emails.
Also note that for 100% accuracy you may need to consider the scenario of a user who is writing an email and adds an attachment, and then deletes it. This could be handled by a plugin running when attachments are deleted, but that logic can get complex (what if two attachments were added but only one was deleted?)
There is some useful sample code for dealing with the ActivityMimeAttachment entity here.
For the second plugin:
A plugin which executes on update of an email would then need to validate the following criteria:
The email direction is outbound (a user has answered an email, e.g. sent a reply)
The email status reason is Sent (the email has actually been delivered and is not saved as a draft)
The email sender and/or owner and/or created by is a real user (filter out automatic and workflow sent emails)
The regarding object is an incident
Then you can implement the required custom validation and logic.
The second item could potentially be achieved using a standard workflow, depending on how complex the custom logic is. If the logic is too complex for a standard workflow, a custom workflow activity might also be useful since additional logic or validation could be added without writing additional code.

For the 1. Plugin: Register on email create and on update (maybe users create the mail first and then update some attachments later)
For the 2. Plugin: Check the following:
plugin context depth should be 1 (this makes sure that no mail created by another plugin is processed)
Check the created by and created on behalf by fields on the email entity to be a non technical users and that no one is acting on behalf of another user creating this mail
Check that regarding object points to incident
If this is not sufficient enough and the users sends mails only via CRM Web GUI you can additionally set a special flag on the record via javascript to make sure that the mail was created using the gui. Than check this status flag in the plugin.

Related

Recipient Delivery Failed -- Webhooks and Correcting/Resending via the API

I've been working on an integration that sends an envelope to 2 signers. I am trying to test and program for the case of 1 of the signers having a bad email address. I would need to:
Be notified of this (webhook?)
Update the email address for the signer
Update the email address in the custom fields as that's printed on the agreement
Resend the envelope
When I enable the delivery failure notification in Connect (this is set up at the account level, for now), I don't see where the failure is noted in the webhook response or for which signer the error is happening.
I've found multiple links via Google talking about "correct and resend" but I haven't been able to get anything definitive in terms of what steps need to be taken or a (PHP) code example. I've also found "resend" in the API reference but still no code examples.
I also haven't seen any code examples (PHP) of how I would update a signer's email address and how that would work via the API.
It'd also be good to know how to update custom field data for both signers so the email address in the contract is updated (it's listed separately as part of the custom form data).
And finally, how would I resend the envelope?
Thank you for your thoughts.
Per DocuSign support (customersupport#docusign.com):
Be notified of this (webhook?)
I have updated your account settings and now you should be able to see AutoResponded in your webhook messages when email invalid or unreachable.
(my comments: so it sounds like you have to ask to be able to see this stuff, it's not part of their standard webhook responses)
Update the email address for the signer
I also haven't seen any code examples of how I would update a signer and how that would work.
Unfortunately we don't have an example for recipient update but the logic is to get list of all recipients, pick the one need to be updated, and update.
You can use below to retrieve all recipients per envelope
https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/enveloperecipients/list/
GET /restapi/v2.1/accounts/accountId/envelopes/envelopeId/recipients
Extract the one you need to update edit email and update using the below
https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/enveloperecipients/update/
PUT /restapi/v2.1/accounts/accountId/envelopes/envelopeId/recipients
You can also see example code in C# how to do this in this thread https://github.com/docusign/docusign-csharp-client/issues/307
Update the email address in the custom fields as that's printed on the agreement
There is bug case created ( above link ) regarding this. At the moment you can not update signer custom fields case EC-2944.
Resend the envelope
You can resend the envelope during recipient update
https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/enveloperecipients/update/
PUT /restapi/v2.1/accounts/accountId/envelopes/envelopeId/recipients
My commentary:
Since custom fields can't be updated, this whole use-case goes out the window. We can't have contracts with incorrect data on it, so my client will have to do these corrections by hand. Kind of a bummer.

Send an email (using flow) when the text field changes in PowerApps

I have a PowerApps App which is linked to a SharePoint List. When the user makes some changes to the text field in the app; I want the flow to send the user an email regarding the update.
I've been trying to track the SharePoint List entry and see if the entry is modified, then send an email. But so far I'm unable to do so.
I've been able to send an email when a text field changes to a specific text; but I'm looking for something where a particular entry in the list is changed.
When an item is created or modified > Condition (Column is equal to Yes) > Send email based on the condition
You don't need Powerapps for the same, what I mean is you need Flow for this.
Create and Run your flow on SharePoint directly.
In your flow check whatever your field is changed, if changed then you can send the user email.
You do not need to depend on Powerapps, Flow can alone work for this scenario.
Ensure you are using the Sharepoint When an item is created or modified Trigger in Power Automate (the tool formerly known as Flow)
Add a Trigger Condition for the column in question. Something along the lines of #triggerBody()?.Status,'Pending')
Trigger Conditions are not very well documented at the moment, but provide a powerful way to control when a Power Automate runs.

Kentico 10 - Custom action on page update

I am looking to perform a custom action when a content editor in Kentico 10 updates a page and it eventually gets published.
To be more specific we have a custom page type for products which also as an "Updated" checkbox allowing the editor to mark it as updated. When this happens (gets marked as updated) I would like to send an email out to users that have a registered interest in this product that it has been updated.
I was looking through the documentation and came across Global Events here: https://docs.kentico.com/k10/custom-development/handling-global-events/reference-global-system-events#Reference-Globalsystemevents-DocumentEvents
I was wondering if using global events to intercept the save action when the editor updates the product is the way to go here or if there is a better approach.
Kentico does n't have this functionality out of the box, but we can achieve this by writing Custom code for Global Event and a scheduler (if No.of mails is large)
Recommended steps:
Attach custom code to Global event handler while publish specific document publish after event
public override void Init()
{
// Assigns custom handlers to the appropriate events
WorkflowEvents.Publish.After += new EventHandler(DocumentPublishCustomEvent);
}
In the custom code, if required page is published then make entries into custom table for email to be sent [This step is optional you can send mail from custom event handler directly if only few mails to be sent]
3.Implement custom scheduler to pick the user info from custom table and send email to user.
Note: Ideally you can use email Template for send emails
Using Global events is one way of doing this, another way would be to use Kentico's Advanced workflow engine (If you have the EMS license):
https://docs.kentico.com/k10/managing-website-content/configuring-the-environment-for-content-editors/configuring-workflows/designing-advanced-workflows
You could create a custom workflow step and action which the editors would put the page into and which would send emails to interested people - https://docs.kentico.com/k10/managing-website-content/configuring-the-environment-for-content-editors/configuring-workflows/designing-advanced-workflows/creating-custom-action-workflow-steps
If you do not have the EMS License, using Global events seems like the way to go, but I don't see the updated flag field as necessary, you could easily check in the global event handler if the product arrived at the "Published" workflow step in the basic workflow and then send the email to the interested parties.

Mail-in database

I have this scenario (this is an old story of mail-in)
This is a company where have many Domino Mail-in databases. One for every branch.
Every person in every branch has a personal Notes Email.
The company policy is that each person of the branch can not send email to an external account (internal yes), so I need to use the mail-in database.
I tried with the rules of Domino to perform a block (in the rule you can set the Sender field to track the mail), but it does not seem possible because unfortunately, when a user sends an email from a mail-in database (mail9.ntf template) the sender field is the username.
I know about Team Mail box project, but this is an old project and I have some problems with HTML outgoing mail and it doesn't work on the web.
I tried looking for a solution, customizing the standard Mail9.ntf template and I discovered that the library "CoreEmailClasses" with the function QuerySave method is executed Me.m_noteUIMemo.Send()
I have tried to change this code copying the backend document into mail.box the mail...but this doesn't work because it is more complicated (there are TMP field...and I observed that when you use .send() into mail.box the RichText is a MIME-RT) .
The only solution that I have found is to save the email and later with a scheduled Sign Agents to Run on Behalf Of the mail-in user that sends the email (solution that I do not like because is not in realtime).
Do you have any other ideas?
UPDATE FOR INOTES
I've found into the FORMS9_x.nsf the subform
Custom_MailMemoDictionary_Lite that contains this code. Now I need to understand how to use it
<NotesComment>
//Use s_MDNToFrom to change the From field in outgoing email. If
//s_MDNToFrom is set, need to also provide From field. Uncomment out the
//dictionary to enable this
</NotesComment>
<NotesComment>
<NotesDictionary>
<notesvar name=s_MDNToFrom value={"1"}>
<notesvar NAME=From value={"Custom From Field"}>
</NotesDictionary>
</NotesComment>
I am not sure if this will solve your problem but we have found that setting the Mail-in name (item name FullName) in the Mail-in Database document to a hierarchical name allows us to setup the owner of the mail-in database as that user. Then mail sent from that database is from the mail-in name sent by the actual user.
For example: use a name like: Branch1 Email/Organization and set the internet email to branch1.email#oraganization.com and then set the owner of the target database to Branch1 Email/Organization
Good luck!
deletes the contents of the subform and paste the following code
<NotesDictionary>
<notesvar name=s_MDNToFrom value={"1"}>
<notesvar NAME=From value={Principal}>
</NotesDictionary>
kind regards

Approve/Reject in email generated by SharePoint

When I make a meeting in Outlook, the recipient gets a approve/reject button in the top of the email. I'd like to do a similar thing with SharePoint: when a task is created, an email is sent to the person the task is assigned to, and the email asks the recipient to either accept or reject the task. I've seen demos of people doing this with a custom ASPx page, but I'd like to make it directly in the email. How should I go about doing that?
I'm used to making workflows in Visual Studio, so I'm happy with code examples for setting up an email and/or parsing the response
Cheers
Nik
The approve/reject buttons in Outlook shows up because the email is in the iCalendar format. I dont know if this is the best way, but you can send out your own iCalendar emails using C# code and set the response email to a mail server you control. From that mail server you can process the email and use the SharePoint WebService API to approve the item in SharePoint.
I like JMD's suggestion but I don't know how you'd interact with SharePoint from the mail server.
It might be a easier to send an HTML-formatted email with two links (...) for the Accept and Reject buttons. You could use CSS to format them so that they look like real buttons.
You could then create an ASPX page (or better an IHttpHandler implementation) to perform an action based on parameters passed to it via a URL. You'd want to pass in the site, web and list details and the list item ID along with a value to indicate whether the item is approved or rejected.
Then set the URLs of your "buttons" in the email to call your handler and pass in the appropriate parameter values.
The downside to this is that the "buttons" would be part of the message body and not part of the Outlook chrome but, on the other hand, they would be usable from any email client.

Resources