Accessing Shared Mailbox sub folders with exchangelib python - python-3.5

I am trying to use exchangelib in order to monitor an e-mail address from a dedicated server without requiring an instance of Outlook be installed. We want to move the emails to a processed subfolder once completed. I have been able to connect to the shared mailbox and see the e-mails within the inbox. When I am trying to move the e-mail to the sub folder I am receiving the error. I used exchangelib to create the subfolder and can see it within outlook and OWA.
What am I doing incorrectly?
Here is the code that I am using:
def _move_to_processed(item):
processed_folder = account.inbox / 'Processed_Test'
item.move(processed_folder)
Error message:
raise ErrorFolderNotFound("No subfolder with name '%s'" % other)
exchangelib.errors.ErrorFolderNotFound: No subfolder with name 'Processed_Test'

Related

python MSAL patch request "The OData request is not supported" marking message as read

my application has Mail.Read.Write permission for MS graph API and the application has restrict policy on exchange online . The restriction is for a security group and the mailbox folder i am trying to access is a member of that security group. get and post methods are working fine only problem is with patch . I need to mark some emails as read after processing them.
r2 = requests.patch(request_url2,
data=json.dumps(request_body2),
headers={'Content-Type': 'application/json','Authorization': 'Bearer ' + result['access_token']})
pastebin_url2 = r2.text
print("The pastebin URL is:%s"%pastebin_url2)
the same API works fine from graph explorer has anyone tried using python msal and requests...any help appreciated
Looks like the message Id changes after moving message to a different folder
so i changed my code to first mark the message as Read in Inbox and then move to a another folder instead of the other way around. I tried with ImmutableId but it also changes after moving message to different folder.

javax.mail.Folder.getMessages() returns empty once the message it has been read by getContent

I need to evaluate content from an email that has been sent to a gmail account.
The problem is when I retrieve the content and close the folder. If I try to connect, open the INBOX folder and getMessages() for a second time then the method return empty.
I have tried setting the SEENflag to false, but it didn't work.
Is there any workaround to retrieve the entire content from the INBOX folder?

How to access a shared folder using python imaplib?

How do you access a shared folder ? This is a shared folder which is visible to other users too. I am currently using outlook where the shared folder is visible along with my personal emails
Following back on my question. After reading enough this seems to work.
While using imaplib and connecting to exchange in python 3
use this,
result, data=mail.login('personal#domain.com\shared#domain.com','personalPassword')
If you have access to this shared mailbox in outlook then you will be able to connect using this. Print the result if it says 'OK' then the code did work.
I believe this is an answer.
Posting a link here for those who are working on similar problem with a python solution.
https://medium.com/#theamazingexposure/accessing-shared-mailbox-using-exchangelib-python-f020e71a96ab
Here is the snippet:
from exchangelib import Credentials, Account
credentials = Credentials('Firstname.Lastname#someenterprise.com', 'Your_Password_Here')
account = Account('**shared_mail_box_name#someenterprise.com**', credentials=credentials, autodiscover=True)
for item in account.inbox.all().order_by('-datetime_received')[:100]:
print(item.subject, item.sender, item.datetime_received)

How to programmatically create a bookmark for another connections user?

We want to create bookmarks programmatically and this works fine if the email parameter matches the account of the currently authenticated user.
The question is, how can we create a bookmark for another user ?
Below is the pseudo we use from the SBT.
String apiPath = "/dogear/api/app";
Response<String> postResponse = restClient.doPost(apiPath).parameter("email","another users email").body(body, "application/atom+xml").asString();
The log files are not very helpful, in the client we get an ERROR 400 Bad Request

Uploading a file to SharePoint copyintoitems throws error

I am uploading files to SharePoint using the API Copy.CopyIntoItems. The upload works when the destination url is given as "http://sharepointserver/sitename". However, when the url is given with the domain name, like
"http://sharepointserver.domain/sitename", then the CopyIntoItems API call fails, and the error returned is "Object reference not set to an instance of an object".
Any idea on why there is a strange behavior when the url changes?
You can not use the url with the domain name, like "http://sharepointserver.domain/sitename" for Copying item
The following answer on SO links to a thread on MSDN, which explains in detail why this behaviour occurs: https://stackoverflow.com/a/2692212/274354
Link to the MSDN thread:
CopyIntoItems errors when using destination URI with FQDN

Resources