Reading Unique mails using gmail API - c#

I am reading mails using Gmail API, where I could successfully download the mails to my system. The idea is to navigate through all the label and download the mails, but that is resulting in duplicate mail downloading, as a single mail can belong to different label.
I tried looking up for label $All to get unique mails but i guess All Mail Label is not supported in latest Gmail API. Is there a way to read unique mails in gmail?

Synchronizing the mailbox can be done using Gmail Synchronization guide:
https://developers.google.com/gmail/api/guides/sync
Use history.list() method of Gmail API with Label ID filter and check for 'messagesAdded' section for Message IDs. You will not get the message body, only IDs, and subsequently have to call message.get() with received Message IDs to get message body.
If a message has multiple labels, history.list() will give you messages directly received in a particular label, hence you will not get the same message twice if you call history.list() with different label IDs.
You can also avoid duplicate messages by handling them in your application by storing each message ID in a cache store such as memcache or an in-memory hash table to avoid processing duplicate messages.

Related

Docusign RestAPI - Send Notification to another email

I am using DocuSign API and sending documents to a candidate for signing. As an admin of the DocuSign account, I get a notification email when the candidate viewed/signed or declined the document. Now all I want is to send this admin notification email to another email via API.
Any idea?
PS: I have to trigger the notification email while sending the documents to the candidate.
Viewed/Signed notifications are always sent to the sender of the envelope via DocuSign (out-of-the-box), and you cannot use API or any other DS settings to re-direct these email notifications to someone else who is not in the workflow. Instead you can opt for one the below two options:
a. Add that person's email address first in the routing order as Carbon Copy recipient, once that person is in routing order then he/she has access to the envelope's history, and can always open the envelope and check the envelope history to know who viewed or signed the envelope. But in this case also this person will not receive any viewed/signed envelope email notifications,but he/she can receive any declined/voided email notification.
b. Use DocuSign Connect which is based on publish/subscribe type architecture. Per below screenshot, you can subscribed for interested trigger events, once those events happen then DocuSign will push an XML message to your listener, and once you receive these XML messages then you can use any other email APIs like Gmail etc, to send email notification to anyone interested in receiving such notifications.
Those notifications go to the owner of the envelope, so if you're okay with losing them yourself you can set up a Transfer Rule so that the alternate email address holds the envelope and gets the Sender Notifications.
Documentation on Custody Transfer Rules is available here: https://support.docusign.com/en/guides/ndse-admin-guide-custody-transfer

linking a received email with a sent email

I have just completed reading received and sent emails using c# console application well that was easy part now the problem is I wanted to know is there a way of linking a received email to its replied/sent email like lets say i create a streamwriter and I write the contents that I need from the received email and the contents from the replied/sent email. How would I then go about knowing the received email to its replied/sent email? How would I link them? Uniquely differentiate from the tons of email?

What is the best way to display an exchange mail message on an ASP.net web page?

I have a list of actions happend on an item listed on an ASP.net website. These actions are logged in a simple sql table linked to the item.
i.e.:
[2013-11-04 18:00]: Problem solved
[2013-11-04 18:00]: Called User
[2013-11-04 14:00]: Mail Received
For this, I will have to query the support mailbox for new mail messages. When a new message is received, a 'mail received' action is created. The 'mail recieved' entry should be clickable so the support user can see the contents of this message.
Question: How do I show this message to the support user?
Using Exchange Webservices Managed API 2.0 I can find this message and his body but the message body can have inline images and other layouts.
Options:
Show the message on the web page try to render the mail message the best way I can.
-> Are there any free plugins that do this? Something like this but that can be used in a web page?
Use Outlook to display this email message.
1&2 combined.. show a preview text-only message and click to see the whole message using outlook.
Since the support user will have Outlook 2010 or higher installed on his machine, the 3th option seems a logical choice but how can I display this message in outlook?
#{
HttpContext.Current.Response.AddHeader("Content-disposition", "inline;filename=message.msg");
HttpContext.Current.Response.ContentType = "application/vnd.ms-outlook";
}
#(new HtmlString(ViewBag.Body))
Obviously doesn't work.. a .msg file seems binary. Do I need an API for this?
But even when this works I will have these problems:
Every time you open a message you will have to click 'Open' to view this message.
-> Can I prevent this in modern browsers (primarily IE10 & IE11)?
-> Or are there 'inline outlook viewers' available?
When this support user answers this message using his outlook, this message will be sent 'from' his account. There would be no trace of this sent message!
-> Can anyone think of a way around this?
We are using an on-premise Exchange 2010 SP3 server that should be migrated to Exchange Online some time next year. Application is running on ASP.NET 4.5 using MVC 5.0 framework.
It could be solution to use this API to download messages as .msg file directly from Exchange server
Tinker with the different body types and retrieval methods. Info here:
http://msdn.microsoft.com/en-us/library/ee217562(v=exchg.80).aspx
See if any of them return something that's relatively easy to display, whether that be parsing the HTML body or showing the RTF body in the browser. I haven't mucked with this much and don't have an Exchange server handy or I'd check myself. If Exchange doesn't chew up the HTML when the message is send, you may be able to parse out the src="cid:contentIdOfAttachment" and replace it with a proper link to the attachment for display in the browser, but Exchange can do funny things to HTML and CSS.
And for clarification, by "support user", do you mean a support employee (ie, tech support) or someone who is receiving support and checking on the status of their ticket? If the message is to be shown and/or replied to in Outlook, would this person be accessing a single support mailbox (perhaps a public folder) or would the message be forwarded/copied to the person's individual mailbox?
If I'm getting this right, you'll be copying it to an individual mailbox, and from there it's "outside" the system, so the reply goes straight to the end user and skips the central support mailbox. You might be able to circumvent this by altering the message before it is sent/downloaded by changing the "from" to the central support mailbox. When the support user responds, it goes back to the central support mailbox, where you can have a secondary sync action (or even the same one that's fetching incoming mail) process it, change the to/from to send to the intended recipient from the central support mailbox, and send it off by using UpdateItems and saving it to the Sent folder. It's not pretty, but it should be possible. That's just off the top of my head, though, so there could easily be a better solution. And I'm operating on a few assumptions about the system you're working in, so maybe I have things a bit wrong.

Remove Duplicate of bulk email received from different user

i have five user using outlook email client. Each of them receiving mails from a email marketing. i need to get all the unique mails from all my five user. i used the following,
Message-ID of outlook email header.
if a same mail received to same user, then Message-ID is same. so that i can able to eliminate the duplicate mails.
if a same mail received to different user, then Message-ID is not same. so that i can able to eliminate the duplicate mails.
is there any better way to eliminate the duplicate mail from different user
As far as I know the message ID is exactly what you cannot use. It is always different. Check the properties of the emails and find similarities and check these. The first is going to be the From then Subject then maybe a part of the body.

How to thread emails using custom headers?

Does gmail preserve x-headers in email replies?
I'm developing an application which threads emails and email replies together using a Thread Id.
I add the header through SMTP .net library with the thread id, using the key X-ThreadId.
If I send it to a gmail account, I can see the header in there in the email source. However if I then reply to it, I want that header to be sent in the reply. It seems to drop that particular header.
Does gmail drop header information in the reply email? Is this a generic problem with email? If so, how do I get round this problem?
I can confirm that Gmail does not add X- headers to the new email when you hit reply button.

Categories