Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recieve Emails from Outlook shared inbox #2

Closed
timoschd opened this issue Jul 22, 2020 · 10 comments
Closed

Recieve Emails from Outlook shared inbox #2

timoschd opened this issue Jul 22, 2020 · 10 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed

Comments

@timoschd
Copy link

Hi,
is it possible to receive the emails from an Outlook shared inbox?
With list_mailboxes() only the personal INBOX can be found.

It would be great to have this feature for working with big company shared inboxes.

@allanvc
Copy link
Owner

allanvc commented Jul 22, 2020

Hi @timosch29,
The name list_mailboxes() gives a wrong impression. It lists the mail folders and not mailboxes. It should be list_mail_folders() and I intend to change its name in the next update of the package, deprecating list_mailboxes(). I am sorry for that. Other functions will have their name changed because of this same reason.
Technicality aside, it should be possible to access a shared mailbox. I've made some research and, in the case of the Exchange Server (Outlook Office 365), it theoretically could be done by informing your username like this in configure_imap():

username = user@company.com\\shared_mailbox

Thus, supposing your shared mailbox name is "shared", and your username is "timosch", you would have:

library(mRpostman)
imapconf <- configure_imap(url="imaps://outlook.office365.com",
                           username="timosch@company.com\\shared",
                           password=rstudioapi::askForPassword(),
                           verbose=TRUE
)

Could you try this and tell me if it works?

Ref.: https://social.technet.microsoft.com/Forums/en-US/336e02ee-6767-4810-90a0-1352bd7cc9e9/office-365-how-to-access-a-shared-mailbox-using-imap-client?forum=onlineservicesexchange

@timoschd
Copy link
Author

timoschd commented Jul 22, 2020

Hi,
thanks for the fast response. I already tried it with the escaped backslash. It is not working.
However it works with the Python module imapclient with a similar schema:

from imapclient import IMAPClient

with IMAPClient(host='outlook.office365.com') as client:
    client.login('timosch@company.de\shared', 'password')
    client.select_folder('INBOX')

    # search criteria are passed in a straightforward way
    # (nesting is supported)
    messages = client.search(['UNSEEN']) 

    # fetch selectors are passed as a simple list of strings.
    response = client.fetch(messages,'RFC822')

@allanvc
Copy link
Owner

allanvc commented Jul 22, 2020

Hi,
I've just realized that I have a shared mailbox in my company and attempted the above using mRpostman and cURL. It seems that libcurl cannot impersonate the user and access the shared mailbox. Unless there is something I am missing, you have two alternatives in the short run:

  1. If this shared mailbox has a password, you can access it directly as it was a personal account using mRpostman.
  2. You can redirect the emails from the shared to your personal mailbox and retrieve them from there using mRpostman.

I am also posting a question on SO and on the cURL mailing list. Let's see if the libcurl guys can elucidate this.

@allanvc allanvc self-assigned this Jul 22, 2020
@allanvc allanvc added bug Something isn't working enhancement New feature or request help wanted Extra attention is needed labels Jul 22, 2020
@allanvc
Copy link
Owner

allanvc commented Jul 22, 2020

from imapclient import IMAPClient

with IMAPClient(host='outlook.office365.com') as client:
    client.login('timosch@company.de\shared', 'password')
    client.select_folder('INBOX')

    # search criteria are passed in a straightforward way
    # (nesting is supported)
    messages = client.search(['UNSEEN']) 

    # fetch selectors are passed as a simple list of strings.
    response = client.fetch(messages,'RFC822')

I've just done a test in Python using my connection parameters and I can't replicate your success. I still get "LOGIN denied" just like in mRpostman and cURL. Perhaps it is something related to the server configuration.

@timoschd
Copy link
Author

timoschd commented Jul 23, 2020

from imapclient import IMAPClient

with IMAPClient(host='outlook.office365.com') as client:
    client.login('timosch@company.de\shared', 'password')
    client.select_folder('INBOX')

    # search criteria are passed in a straightforward way
    # (nesting is supported)
    messages = client.search(['UNSEEN']) 

    # fetch selectors are passed as a simple list of strings.
    response = client.fetch(messages,'RFC822')

I've just done a test in Python using my connection parameters and I can't replicate your success. I still get "LOGIN denied" just like in mRpostman and cURL. Perhaps it is something related to the server configuration.

I checked again with a different shared folder and it works. Did you make sure IMAP is activated and that you added the shared folder to your account in Outlook? Generally one should also use an escaped backslash in Python like timosch@company.de\\shared to be sure not to have types like \t \n \b in the string. Is it working for you without the shared folder?

@allanvc
Copy link
Owner

allanvc commented Jul 24, 2020

I've tried it, but without success either. Did you tested it using cURL from the command line?

curl --url "imaps://outlook.office365.com/" --user "timosch@company.de\shared"

@timoschd
Copy link
Author

timoschd commented Jul 24, 2020

I've tried it, but without success either. Did you tested it using cURL from the command line?

curl --url "imaps://outlook.office365.com/" --user "timosch@company.de\shared"

I tested it with the shared folders working in Python via cURL without success in those variants:

curl --url "imaps://outlook.office365.com/" --user "timosch@company.de\shared:password"
curl --url "imaps://outlook.office365.com/" --user "timosch@company.de\\shared:password"
curl --url "imaps://outlook.office365.com/" --user "timosch@company.de%5Cshared:password"

Without the shared folder it works. The return was:
curl: (67) Login denied

@allanvc
Copy link
Owner

allanvc commented Jul 26, 2020

Sorry for the late response.
Someone on the cURL mailing list has made a couple of suggestions. They didn't work for me, though.
Can you try it and see if it works for you on cURL?

My version of Curl's manpage says this about --user:

"To specify the domain name use either Down-Level Logon Name or UPN (User Principal Name) formats. For example, EXAMPLE\user and user@example.com respectively."

So I wonder if Curl is noticing the backslash and interpreting your input as domain="allan@company.com" and username="sharedmailbox". Or maybe Curl is NOT interpreting it that way but that's how Exchange is expecting it.

Maybe Curl is interpreting your input as username="allan" and domain="company.com\sharedmailbox".

Have you tried any variations of the down-level logon name format? E.g. "COMPANY\allan\sharedmailbox"? Or maybe the reverse? E.g. "sharedmailbox@allan@company.com"? Just some guesses to maybe trick whatever wrong interpretation is happening into behaving._

@timoschd
Copy link
Author

Hi, I tried both versions with :password at the end. They seem not to work with me, too.

@allanvc
Copy link
Owner

allanvc commented Jul 30, 2020

Sorry for the delay. This seems to be a libcurl’s limitation. I will open an issue on their repo. Let’s hope they come up with a solution soon.

@allanvc allanvc closed this as completed Nov 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants