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

How to subscribe shared mailbox #175

Closed
duongkha opened this issue Mar 29, 2017 · 15 comments
Closed

How to subscribe shared mailbox #175

duongkha opened this issue Mar 29, 2017 · 15 comments

Comments

@duongkha
Copy link

Hi,

I am trying to use the AutoDiscover to subscribe new email event from a shared mailbox. This is what i am trying to do:

_let exchange = this.exchange = new ews.ExchangeService(ews.ExchangeVersion.Exchange2013);
exchange.Credentials = new ews.ExchangeCredentials(username, password);
exchange.Url = new ews.Uri('https://autodiscover.domain.com/autodiscover/autodiscover.svc');
exchange.UseDefaultCredentials = false;
exchange.AutodiscoverUrl('')

after this function i will call to subscribe stream from all folders

_exchange.SubscribeToStreamingNotifications

However, i see it seems does not work at all.

Can you help to advise me how i can subscribe new email from a shared mailbox?

Thanks.

@gautamsi
Copy link
Owner

autodiscover needs rewrite. once I finish TimeZone, I will work on AutoDiscover.

you may not need autodiscover if you know server url. check what URL you get when you perform exchange.AutodiscoverUrl('')

@duongkha
Copy link
Author

Yes, I know the Url already. So, i just need to set the Url from AutodiscoverUrl method to the exchange.Url and then just subscribe as normally, right?

Actually, I can do this just simply by C# code and use Microsoft EWS service without problem and just simple. I am confused how to use your library in nodejs code now.

Can you help to advise me how i can declare a FolderId from you Library and subscribe for only that folder?
This is how i am doing:

  _var folderIds = [];
  var folderId = new   ews.FolderId(ews.WellKnownFolderName.Inbox,'sharedmailbox_emailaddress');
  folderIds.push(folderId);
  exchange.SubscribeToStreamingNotifications(folderIds,self.eventTypes)_

However, it threw error at SubscribeToStreamingNotifications call. It seems does not work.

Please help.

Thanks.

@gautamsi
Copy link
Owner

what is the error message? can you share soap xml from debug log?

@duongkha
Copy link
Author

I try to run debug and see it threw error in this ews-javascript-api\js\Core\Requests\MultiResponseServiceRequest.js

function

MultiResponseServiceRequest.prototype.Execute = function () {

Error message:

TypeError: this.Mailbox.WriteToXml is not a function

I think that i declared wrong type of mailbox in folderId.

What do you think?

@duongkha
Copy link
Author

OK. I know how to work with it now.

var mailbox = new ews.Mailbox(emailaddress);

However, i still got the Unauthorize (401) issue from ServiceRequestUnauthorizedException while the credential should be correct.

Do you have any idea for me to try with?
Please advise

@gautamsi
Copy link
Owner

you need to assign permission to mailbox. are you able to open shared mailbox using c# library using same credential?

@duongkha
Copy link
Author

Yes. It is working with C# and it is just simple to subscribe the shared mailbox.

@gautamsi
Copy link
Owner

point me to sample c# code, will take a look.

@duongkha
Copy link
Author

duongkha commented Mar 29, 2017

https://blogs.msdn.microsoft.com/emeamsgdev/2013/04/16/ews-streaming-notification-sample/

This is code i tried to modify to test:

ExchangeService ex = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
ex.Credentials = new WebCredentials(this.textBoxUsername.Text, this.textBoxPassword.Text);
ex.AutodiscoverUrl("sharedmailboxaddress");
StreamingSubscription subscription;
FolderId SharedMailbox = new FolderId(WellKnownFolderName.Inbox, "sharedmailboxaddress");
FolderId[] selectedFolders = SelectedFolders();
selectedFolders[0] = SharedMailbox;
subscription = ex.SubscribeToStreamingNotifications(selectedFolders, SelectedEvents());
var connection = new StreamingSubscriptionConnection(subscription.Service, (int)numericUpDownTimeout.Value);
SubscribeConnectionEvents(connection);
connection.AddSubscription(subscription);
connection.Open();

@duongkha
Copy link
Author

I try to use WebCredentials instead of ExchangeCredentials, however, your lib throws exception of Not implemented

WebCredentials.ts - AdjustUrl : Not implemented.

Do you suppot the WebCredentials yet?

Thanks.

@gautamsi
Copy link
Owner

only ExchangeCredential is supported

@duongkha
Copy link
Author

duongkha commented Apr 7, 2017

@gautamsi : how can i authenticate to EWS by NTLM authentication? My mail server is hosted on-premise and only support NTLM authentication. I always get 401 error when trying to access. Please advise.

@gautamsi
Copy link
Owner

gautamsi commented Apr 7, 2017

@duongkha about NTLM - see my response in #173

the c# code does not work as there is no operator overloading in javascript. you already have that covered by using Mailbox object instead of email address string. if you have only NTLM/v2 and getting 401 error, then you should be fine with my #173 comment.

if you have not enforced NTLM v2 then you can consume ews-javascript-api-auth package (see readme there).

@duongkha
Copy link
Author

duongkha commented May 3, 2017

@gautamsi : I don't have issue with authentication now anymore since i don't need to do with NTLM. For now I only have problem with listening new email. Sometimes, Open() is not success without error thrown. Then my listener is stopped listening the new email.

@gautamsi
Copy link
Owner

gautamsi commented May 3, 2017

track in #174

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants