Count of messages in mailbox using Outlook REST API - outlook-restapi

https://outlook.office.com/api/v2.0/me/messages?$count=true seems to return wrong value. Though I have only 31 messages in the mailbox, it gives count as 201. Has anyone been able to get the correct count of messages using the above API?
Also, Is there any other Outlook REST API that can be used to get the count of messages in the outlook mailbox?

Querying /me/messages?$count=true will return the total across all folders in your mailbox. When you say only 31 messages, do you mean in the Inbox, or across all of your folders?

Related

LogicApps outlook.com connector GetEmails trigger - get oldest emails

I am trying to get oldest emails from outlook.com mailbox within LogicApp. I have done number of test and seems like both triggers available GetEmails and GetEmails(2) always start from the newest messages.
My use case:
Emails after processing are moved to Processed folder and shall be stored there for a month. So am looking for a way to get list of x number of oldest emails to check whether they are older than 30 days, and delete them if condition is met.
With the current functionality, I would have to get all the emails from the folder, what might be few thousands within 30 days time slot. This creates an unnecessary workload on the outlook.com but also within LogicApp. Additionally I am afraid I can reach thresholds for this connector.
Is there a way to get x number of emails starting from the oldest ones?
If you want to get top X oldest emails in a folder of outlook mailbox, you can use Microsoft Graph API by Http action in Logic App to get emails you want directly.
For instance , if I want to get top 5 oldest emails in Processed folder, use the API below :
GET https://graph.microsoft.com/v1.0/users/<username>/mailFolders('Processed')/messages?$orderby=receivedDateTime&$top=5
In logic App :
I have tested on my side and it works perfectly for me.
Details of Microsoft Graph outlook mail API see here .
And how to customize responses from API
And Auth for Microsoft Graph API.
If you have any further concerns, pls feel free to let me know.

Reset unread message count for Facebook page (Facebook Graph API)

I am trying to build a small Python tool to connect our Helpdesk software (Helpscout) with our companies Facebook page to be able to receive and answer messages from clients directly from within Helpscout.
I am using the conversation endpoint to grab all unread conversation:
conversations = api.get_object('[page_id]/conversations?fields=messages.limit(20){message,from},name, unread_count,message_count')
The problem is, once I read the messages the unread counter still stays the same until we open those messages directly from within the Facebook page. Spent lots of time to find a solution, but apparently there is no option to reset the counter or handle it any other way.
As a workaround I currently use the overall message count and compare it every time I check for new message to only load the new ones. That works fine, but there is still the issue that all messages stay unread on the Facebook page and will be all loaded again with every API call until we manually click them.
Thought about using Selenium to just do this job 1 time per day and clean the inbox, but don't really like this. Any idea how to solve this? Maybe I missed some API feature which can help?
I use the Send API to send the messages back to our customer, but could also not find any option to update the conversation in any way to handle it:
data = {"recipient": {"id": "xxxxx"}, "message": {"text": message}}
response = requests.post('https://graph.facebook.com/v3.2/me/messages?access_token=xxxx', headers=headers, data=json.dumps(data))
Maybe it is possible to move the conversation from the regular inbox to "Done" folder which could solve it?
After doing some research I found a solution to it here:
FbChatBot mark message as Read
You cannot update the unread count, but you can let all conversations automatically move to the "DONE" folder to let them not show up in your inbox anymore by using the "Handover Protocol": https://developers.facebook.com/docs/messenger-platform/handover-protocol
The app has to be set as 'Primary Receiver' and 'Page Inbox' as 'Secondary Receiver'.
All conversations will be moved to "DONE" now. Just make sure to set the correct permissions in the messenger webhook settings:
There will be no error without it, but messages will stay in the inbox and it does not work.

Javamail pull messages in chunks (like pagination) GMAIL POP3

Through Java app I am able to connect with GMAIL POP3 server. When I call getMessageCount() it returns me 280, though I have more than 10k mails in my Inbox. So, when I call folder.getMessages(300, 400) it gives me error because range is more than 280. For more details see my another post link
My question is:
Is their any API to get pull emails in chunks (like as pagination)? if so can anyone give me reference to start with it.
This is not a javamail limitation, this is a gmail limitation of their POP3 server. When accessing over POP, it will only show you 300ish messages at a time until you remove them. There is an alternate access method where you specify the login as recent:user#gmail.com, where instead it will show you the last 30 days worth of email.
They do this because POP3 rapidly becomes a very inefficient protocol for accessing thousands of emails, so they limit the window of messages you can see.
If you wish to access all the email, you will need to either switch to IMAP, or use the Gmail REST API, both of which have vastly improved mail access and experiences.

Excel Auto Send Emails via Outlook Randomly NOT Sending

I've inherited development of an Excel userform which contains a send button to return the user's data back to a central mailbox. The tool has just been rolled out to a larger community and some users are experiencing emails not being sent. These are random events as the users can sometimes send the forms and it is not form specific.
The tool uses the following code to create the email:
Set ObjOL = CreateObject("Outlook.Application")
Set ObjOutMail = ObjOL.CreateItem(0)
and is sent via:
ObjOutMail.send
We had tested this with a number of users and never had any problems, but we now have a number of users who have successfully sent 1 or more forms but 1 or more have also failed, and they also can't resend the successful forms any more either.
There are no error messages, the Outlook "this could be a virus, etc." confirmation is fired as usual (we have not attempted to circumvent this) but there is nothing in the 'Sent Items'. The users are also able to send conventionally generated emails so there is no mailbox limitations going on.
The Userform is modal and upon sending copies the three user fields to "Sheet1", saves itself and mails itself.
Really at a loss to understand what's going on.
Thanks for any advice.
EDIT: To add we are still using Office 2003 on Win XP.
Thanks for all the replies, using the .display property showed me what was up.
The email is addressed to what I thought was an explicit address, however there is an extra '(MULTIUSER)' post fix which I didn;t realise was actually part of the address, DOH!.
Last week and similar mailbox made up of the same address but with a different postfix was added to the system. This ment Outlook couldn't resolve the address and didn't send the emails.
Thanks again.

Maximum sending rate and daily quota for Gmail+Google Apps Script?

I wrote a small Google Apps Script to send out personalized e-mails (conference invitations) individually to recipients (i.e. one recipient per e-mail). As a workaround to the issue of e-mails sent using GmailApp.sendEmail not showing up in the Sent Mail folder, I have one script send the e-mails to itself (i.e. the sender and recipient are the same), then another script to forward those to the appropriate recipients. There are only about 100 (maybe less) verified recipients, but I'm concerned that sending out the e-mails as fast as the script executes might get them flagged as spam due to the rate at which they are being sent. My questions are the following:
If a Google Apps Script accesses a Gmail account to send and forward e-mails using GmailApp, does it incur a sending rate limit (e.g. in e-mails/second, kB/second, etc.)?
Which quota applies to said script? Is it Gmail's 500/day or Google Apps' 100/day?
P.S. I found this discussion about quotas, but I'm not sure if my case falls under either of the scenarios described therein.
There are no such limits. There is a limit on the body size per email - 20KB
It's 500 emails/day for Gmail users and free Google Apps users. Please note though that CCing and BCCing are all counted against your quota. So if you send one email and CC it to 500 hundred people you would have used up all your quota for that day. Also, there are additional quotas when sending emails within a domain.
Also, the method MailApp.getRemainingDailyQuota() will tell you how many more emails you can send that day.
All the quotas are described here:
https://developers.google.com/apps-script/guides/services/quotas
How are e-mails sent using GmailApp.sendEmail not showing up in the Sent Mail folder?

Resources