SendBulkMailRequest Class - c#

I'm writing custom workflow in Dynamics CRM. Has anybody used SendBulkMailRequest Class? This class we used for sending bulk mail to the contacts and the scenario is like, sending a bulk mail and later update the field in other entity for every successful mails sent.
Here is the reference link of the class. Suggestions are appreciated.

You are sending Bulk Emails to Contacts, then you are tracking the Email sent flag in Opportunity record. I assume you are having a way to find out the right opportunity to update from the contact in Email recipient. (Just curious - What are you setting as regarding of those Emails?)
My recommendation: Register a plugin on Email create, then retrieve the contact's opportunity, set the flag IsMailSent to true & do a Service.Update(Oppty)
I guess SendBulkMailRequest message is just like broadcaster, as I noticed the below comments inside code sample.
// When the bulk email operation has completed, all sent emails will
// have a status of "Pending Send" and will be picked up by your email
// router. Alternatively, you can then use BackgroundSendEmail to download
// all the emails created with the SendBulkEmail message.
// See the BackgroundSendEmail sample for an example.

Related

how to add attributes (application-specific data) to a Twilio SMS - 2021

I am working on an appointment confirmation system where I need to bind the SMS response 'Y' or 'N' to some meta data and send that meta data to my API via the Twilio webhook.
I am using.NET SDK from Twilio and trying to add attributes to the SMS message (MessageResource) which their documentation states:
Attributes:
STRING PII MTL: 30 DAYS
"The JSON string that stores application-specific data. If attributes have not been set, {} is returned."
link to docs: https://www.twilio.com/docs/chat/rest/message-resource#message-properties
which is more like metadata which is what I need but when I try finding any 'attributes' property in my C# code with their SDK I can't find it.
Here's my code:
var twilioMessage = MessageResource.Create(
body: msg,
from: _configuration["Twilio:FromPhoneNo"],
to: new PhoneNumber(phoneNumber),
attempt:1,
attributes: "{"id":"test"}" //this property doesn't work
);
var attributes = twilioMessage.attributes; //this doesn't work either
Any help will be highly appreciated.
Twilio developer evangelist here.
I'm afraid you are looking at the wrong documentation for sending SMS messages there. This documentation is for sending a chat (app to app) message. The documentation for sending an SMS is here.
Sadly, SMS messages do not have the ability to bind custom attributes to them. It is simply something that doesn't exist in the protocol.
You are sending an appointment confirmation and expecting a "Y" or "N" response. I am guessing you are trying to add the ID of the appointment in the case that you send confirmations for more than one appointment to the same phone number and you need to work out which appointment the response is about. There's a further issue here in that, as an end user, you cannot reply to a specific SMS messages. SMS is purely chronological.
There are 3 ways I can think of to work around this:
Only send one confirmation at a time. If you are still waiting for a response to a confirmation, don't send another one until you get that response. This might not work if users don't respond to confirmations.
Have the user include the ID of the appointment in the response. This is flaky because it relies on the users getting things right and you want to make things as simple as you can for them
When you need to send more than one confirmation at a time, use different Twilio numbers to send the confirmations. Then you can tie the confirmation response to the appointment by inspecting the Twilio number that the user sent the message to.
Number 3 is the most sound way of doing this. It shouldn't require you to have too many extra numbers, just as many as you might have concurrent appointment confirmations.
Let me know if this helps at all.

Notification on sent out email using EWS

I have done streaming notification on new arrival email but when ever user send any email to anyone, Can it generate any event though streaming, pull, push notification. I am trying to track each and every email body that is being sent out from account.
There is no Send notification that gets fired however when a user sends an email the default behaviour is to save a copy in the SentItems folder so if you subscribe to the CreateItem event on the SentItems folder that should probably cover what your trying to do (you can test that without writing any code using the EWSEditor).
You can configure the Email Client to not save a copy in the SentItems folder and if the user is trying to hide something they may delete it before you can get at it. Transport Agents or Jornaling should be used when you need to do this kind of thing for auditing/compliance reasons because it ensure you always capture the message.

How do I create a webhook for sendgrid in c#?

I am new to using Sendgrid emails using c# .Net library. Our requirements wants us to track the status of the email like Delivered/Went to Spam/Client opened/reported as spam etc., By looking at the documentations and answers from other users to my previous questions its my understanding that there is no direct way to track the status of the email (like result object).
It would be really helpful if someone can point me to some example/sample codes or documentation/implementation in C# for the following
1) Adding unique parameters while sending the email using send grid API. Can I use a Guid string as my argument
I am assuming what I am doing below is correct.
var myMessage = new SendGridMessage();
var identifiers = new Dictionary<String, String>();
identifiers["Email_ID"] = "Email_ID";
identifiers["Email_Key"] = "9ebccd0d-67c0-4c28-bbf3-83d5bb69f098";
myMessage.AddUniqueArgs(identifiers);
2) How to use event webhooks to get the status with the unique argument that I used above from the http_post so that I can associate an email to the status. Any sample code , documentation in c# or an overall idea of how this works will get me started on this.
Appreciate your time and answers.
Sending emails via SendGrid is easier from C# using the official library that SendGrid provides. From your code example, it looks like you may already be using this - good job.
The unique argument should work as long as its been stringified, and you're not trying to pass an object to myMessage.AddUniqueArgs.
The Event Webhook will send a JSON packet to any URL that you specify. If you have included unique arguments in an email that you send out via SendGrid then these are automatically added to each event response you get back from the webhook - you don't need to turn anything else on to get the arguments as well.
There is an example of this call and the resulting response in the SendGrid Documentation.
SendGrid has an Event Webhook which posts events related to your email
activity to a URL of your choice. This is an easily deployable
solution that allows for customers to easiy get up and running
processing (parse and save) their event webhooks.
This is docker-based solution which can be deployed on cloud services
like Heroku out of the box.
https://github.com/sendgrid/sendgrid-csharp/tree/main/examples/eventwebhook/consumer

Detect auto reply emails programmatically

I have scenario where I would have to track the delivery of the emails I send programmatically and flag those recipients who have set either 'Out of Office" OR have the message delivery failed due to over-sized inbox OR if their email ID doesn't exist. Such instances usually send out automated replies. How can I track them? Does .NET (System.Net.Mail) offer any APIs to do it?
There's no set of checks for auto-responses that produce perfect behavior (detect all auto-replies with no false positives), but the following checks have worked well so far:
header Auto-Submitted with value other than no (see RFC
3834)
headers X-Autoreply or X-Autorespond with any value
header Precedence with value auto_reply
I don't yet have any advice for detecting message delivery failure notifications.

Outlook Add-In - Custom Headers for Email Tracking

We have written an Outlook add-in in C#, that appends a custom header to outgoing messages.
This add-in has to use a library called Redemption to bypass Outlook's security to modify the headers, and this is all working great.
Our problem lies when sending outgoing mail through an exchange server. We use the additional header as such:
Add a References header with an email address that includes an ID for tracking with our system.
This is a standard email header that all mail clients should pass on when replying to messages. So replying to a message will automatically keep the new message tracked.
All of this works just fine if you send an email from an IMAP account setup in Outlook such as GMail.
Problem is, if you send mail via an Exchange account, the Exchange server overwrites the References header and uses it's own proprietary headers: Thread-Index and Thread-Topic. Email standards suggest to use References and In-Reply-To headers. See this link on this issue.
Does anyone know a way around this? Some algorithm to gain us the following:
Add a header (of any name or kind) to emails that includes a 10-digit ID and 3 letter prefix
Replying to this email from all (or most) mail clients preserves the custom header
I think the following algorithm is going to solve our issue:
Our Outlook add-in will set the References and an arbitrary X- header
Our mail filter will look for References, if found use it (if outgoing mail server was Exchange, it will not be present)
If our mail filter finds the arbitrary X- header and a Thread-Index, it will store the data found in the X- header.
Later if the email is replied-to several times, the mail filter will use the Thread-Index to look up the past info to keep the email tracked.
For those wanting to know internals of the Thread-Index header, it is a Base64 encoded string. The first 22 bytes are the original unique portion and each reply adds an additional 5 bytes on to it. We only use the first 22 bytes to identify the email.

Categories