Extract single messages from gmail thread (Objective-c) - objective-c

I am trying to fetch gmail emails with IMAP (in objective-c), and I want to separate, for every thread, every single message that has been sent in the conversation. To make myself more clear, imagine a conversation like this one:
John says : Hi Mike, that's the first email
Mike replies : Hey John, how are you ?
John replies : Great Mike, thanks.
If I get John's emails through IMAP, I will fetch only one email, that will be :
Hey John, how are you ?
On Wed, 21 May,
Hi Mike, that's the first email
And I would like to get two different messages out of this one email I fetched.
First message would be "Hi Mike, that's the first email"
Second message would be "Hey John, how are you ?"
I looked at the message-id field in the header, but I can't figure out how to link that back to actual messages.
Any ideas?
Thanks !
[EDIT] : So far I can parse the email in John's inbox and extract the associated string containing the message. But what I want is the actual message (with the header and all), not just the string containing the message.

Gmail has a very nice IMAP extension to do this. I've never tried to use the objective-c libraries, though.
If you want to do this for one conversation, you need a message to start with. Any message in the conversation will do. First, you retrieve the X-GM-THRID of that message: a uid fetch 23451345 x-gm-thrid, which gives you a 64-bit number, perhaps 9876543876543444423. Next, you look for the other messages in the same conversation: b uid search x-gm-thrid 9876543876543444423, which gives you the UIDs of all messages in that conversation, and you're done.
If you want to do it for all the conversations in the inbox, you issue c uid fetch 1:* x-gm-thrid, which gives you a set of message-conversation tuples: "message 123 belongs to conversation 9876543876543".
If you want to order the messages within each conversation, the easiest way is probably to retrieve the internaldate item and sort by that. Gmail also has an x-gm-msgid but I haven't looked to see whether it's useful for sorting.

Related

URN Filter to Ignore Emails

I am using UiPath's Get Outlook Mail Messages component to obtain emails.
My only request has been to ignore any emails that are Replies, so contain "RE:"
In my email filters I had tried the below:
#SQL=urn:schemas:httpmail:subject NOT LIKE 'RE%'
Unfortunately, I receive the error "Get Outlook Mail Messages: Cannot parse condition. Error at "#SQL=((urn:schemas:httpmail:subject NOT ...".
When I try the filter: `
#SQL=urn:schemas:httpmail:subject LIKE 'RE%'
I am able to obtain all emails that contain 'RE:' but as specified, I want to omit these.
Would anyone be able to advise how to Omit these emails? I need to obtain every other email in the Inbox so makes more sense to just ignore the Replies.
Thanks,
Your code is very close to being correct. The NOT keyword does work, just the placement is incorrect, unlike normal SQL where the NOT would be before the LIKE, in this case it would come before the field name.
So rather than:
#SQL=urn:schemas:httpmail:subject NOT LIKE 'RE%'
It would be:
#SQL=NOT urn:schemas:httpmail:subject LIKE 'RE%'

How to get displayName (Name, Surname) from external organization smtp address in Outlook API?

all, and thanks for your support.
I have a list of e-mails (ex: johndoe#company1.com, maryjane#company2.com) and need their DisplayTo names.
By "DisplayTo" I mean the name that appears after the first e-mail is sent ("ABC" in red).
So it should be something like "John Doe" or "Jane, Mary", which is how future e-mails to them appear (only the first one appears as name#company.com).
The Address Catalog only has internal company e-mails. I could not find a way to get this information in Outlook API documentation, is there a way to do this?
Thanks a million!
Pass the SMTP address to Namespace.CreateRecipient (returns Recipient object). Call Recipient.Resolve, then use Recipient.AddressEntry.GetExchangeUser.FirstName/LastName/etc (error / null checking omitted).

Get The Latest Email From EWS

Can anyone help me, I need to retrieve only the very latest email in my exchange server inbox.
I don't need any other email to show up with the one I want.
But I'm stuck, since the farthest that I could get is only the email I received only today.
I use SearchFilter with DateTimeReceived :
Here's the snipped of my code for the filter :
Dim search As New SearchFilter.IsGreaterThanOrEqualTo(ItemSchema.DateTimeReceived, DateTime.Today.Date)
Thanks in advance.
Just sort your search results by the DateTimeReceived property, in descending order.
view.OrderBy.Add(ItemSchema.DateTimeReceived, SortDirection.Descending);
Then when you loop through the results, the first email will be the latest (and then you can jump out of the loop).

How to send a message using iChat and AppleScript

I have a need to send a message to a number of people to let them know when an event is occurring. It is always the same list of people, and always the same event, so I would like to script it.
The problem that I have is that I know that I need to use the send command to send the message. And the format of that command is
tell application iChat to send "message" to _buddy_
The problem is how to get that buddy. I know how to get the list of all buddies, and to loop over them:
tell application "iChat"
repeat with myBuddy in buddies
end repeat
end tell
What I can't seem to find is how to just get the buddies that I care about, for example those with name "Pietje Piet" and "Joe Anonymous", and then just to send messages to these two contacts.
You'll have to aquire a list of the buddies you care about in a separate list somehow. Here's a suggestion:
set peopleICareAbout to {"Pietje Piet", "Joe Anonymous"}
tell application "iChat"
repeat with myBuddy in buddies
--get properties of myBuddy
if full name of myBuddy is in peopleICareAbout then
send "dfgdgdf gdg dfg dfg" to myBuddy
end if
end repeat
end tell

Is the checkin object's type=mayorship notification appears fickle?

I have some questions about 4sq's API.
Chceckin object obtained by checkins/add endpoint's response sometimes has mayorship field and at other times not.
And mayorship's checkins count field seems not reliable (often appears count 0, but actual count is 2).
Is it so?
thanks.
The notification only contains mayor information if the user is somewhat close to being able to claim the mayorship.
As for incorrect checkin counts, you'll need to provide an example response for us to be able to debug.