Closed jwhugheskp closed 5 years ago
The error you are getting is Not Found. This means the resource can not be found. Try the same queries under the graph explorer. It it returns the same error it is unrelated to this library.
Also, I've tried a query on one of the shared mailboxes of my company and on my personal inbox and it works as expected.
INFO:O365.connection:Requesting (GET) URL: https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages
INFO:O365.connection:Request parameters: {'params': {'$top': 50, '$filter': 'createdDateTime gt 2018-12-31T23:00:00+00:00'}, 'allow_redirects': True}
...
INFO:O365.connection:Received response (200) from URL https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages?%24top=50&%24filter=createdDateTime+gt+2018-12-31T23%3A00%3A00%2B00%3A00
INFO:O365.connection:Requesting (GET) URL: https://graph.microsoft.com/v1.0/users/shared@mycompany.com/mailFolders/Inbox/messages
INFO:O365.connection:Request parameters: {'params': {'$top': 50, '$filter': 'createdDateTime gt 2018-12-31T23:00:00+00:00'}, 'allow_redirects': True}
...
INFO:O365.connection:Received response (200) from URL https://graph.microsoft.com/v1.0/users/shared@mycompany.com/mailFolders/Inbox/messages?%24top=50&%24filter=createdDateTime+gt+2018-12-31T23%3A00%3A00%2B00%3A00
This is what I've done:
import datetime as dt
# ... creating account instance, etc.
my_mailbox = account.mailbox()
shared_mailbox = account.mailbox('shared@mycompany.com')
my_inbox = my_mailbox.inbox_folder()
shared_inbox = shared_mailbox.inbox_folder()
q = my_inbox.q('created_date_time').greater(dt.datetime(2019, 1, 1))
print(my_inbox.get_messages(limit=50, query=q)) # returns 200 ok
print(shared_inbox.get_messages(limit=50, query=q)) # returns 200 ok
Also, be sure to have the latest version installed. Run pip install --upgrade O365
Thanks @janscas. I tried your suggestion and it worked for my mailbox and phishing@kp.org. It still doesn't like spam@kp.org. I have to talk to the mail team and see if we can figure out the differences. Also thanks for the website. I've never seen that one.
Regards, Joe
This might have more to do with the shared mailbox permissions but if so I can't figure out what to ask the mailbox team. I'm hoping someone can provide a direction.
I've got code that reads new email from 3 different mailboxes. One is my work email. The other two are shared mailboxes. When I run the code I get this error
What happens is I get email for my account and from the phishing account, but the code then errors on the spam mailbox. I think the issue is some difference between the phishing and spam accounts, and not with the 0365 code. I am listed as owner on both phishing and spam. I can't figure out what permission would be missing that could cause this. I'm looking for ideas.
TIA, Joe