Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
medhanafi
@medhanafi
Thank you I appreciate your help
medhanafi
@medhanafi

Hello
I come back with a new question.
I try to resolve a Name using

NameResolutionCollection response = this.service.resolveName(name, ResolveNameSearchLocation.DirectoryThenContacts, true);

Is there a way to return more than the 100 as provided by the documentation ?
Thank you

Pavel Kropachev
@pkropachev
As far as I know limit (100 items) in ResolveNames is a hard limit and it can't be changed.
https://docs.microsoft.com/en-us/exchange/client-developer/web-service-reference/resolvenames-operation
You should make request with more precise name to decrease number of items. Maybe something wrong in your business logic if you receive more than 100 results on one request.
prvigneshkumar92
@prvigneshkumar92
Hello
I am not able to fetch InternetMessageHeader for the Mails in SentItems
Is there a way to fetch the emails
MessageHeader
@pkropachev
And I have one more query... Is there any easy way to fetch emails across nested subfolders in Inbox
Pavel Kropachev
@pkropachev
  1. As far as I know, Exchange doesn't store "InternetMessageHeaders" for items in "Sent Items" folder. Headers are added to messages when they go through transport.
  2. Common way of fetching items from subfolders doesn't look difficult. Retrieve all subfolders of "Inbox" folder and then retrieve items for each sub-folders.
prvigneshkumar92
@prvigneshkumar92

Thanks Paval I was able to achieve what I intended. Now I have some queries regarding push notifications. @pkropachev @serious6 @vboctor @ahaarrestad

I have successfully subscribed to push notifications and I have developed a Servlet listener and I am able to receive notifications. But I am not able to parse the XML. HttpServletRequest.getInputStream.available(); always returns value as zero. I am not sure whether I am receiving the right XML. If yes Kindly guide me where I am getting wrong.

Kindly find the below code snippets for your reference

Subscription code

URI callback = new URI(https://vignesh.local.com/msexchange/pushnotification?uniqueKey=b057db49-8238-488c-bebd-7b2e54f9cf31);
PushSubscription pushSubscription = service.subscribeToPushNotificationsOnAllFolders(callback, 1, null,EventType.NewMail,EventType.Created,EventType.Deleted,EventType.Copied,EventType.Modified,EventType.Moved);

MSExchangePushNotificationListener code

public class MSExchangePushNotificationListener extends HttpServlet {

private static final Logger LOGGER = Logger.getLogger(MSExchangePushNotificationListener.class.getName());

public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

    try {
        LOGGER.log(Level.WARNING,"------MSExchangePushNotificationListener POST Called----");
        MSExchangePushNotificationDataProcessor dataProcessor = new MSExchangePushNotificationDataProcessor();
        dataProcessor.processData(req, res);
    } catch (Exception exc) {
        exc.printStackTrace();
    }
}

}

MSExchangePushNotificationDataProcessor

public void processData(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

InputStream inputStream = req.getInputStream();
      LOGGER.log(Level.INFO,"InputStream value is "+inputStream.available());

}

itadder
@itadder
anyone around
how do I read the contacts notes in ews
Pavel Kropachev
@pkropachev

@itadder

void retrieveAllContactNotes() {
    try {
        ContactsFolder contactsFolder = ContactsFolder.bind(service, WellKnownFolderName.Contacts);
        ItemView view = new ItemView(contactsFolder.getTotalCount());
        view.setPropertySet(new PropertySet(BasePropertySet.IdOnly));
        FindItemsResults<Item> contactItems = service.findItems(WellKnownFolderName.Contacts, view);

        for (Item item : contactItems) {
            if (item instanceof Contact) {
                Contact contact = (Contact) item;
                contact.load(new PropertySet(ContactSchema.DisplayName, ContactSchema.Body));
                System.out.println("Contact name: " + contact.getDisplayName() + "\nNotes: " + contact.getBody());
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

See #132.

Pavel Kropachev
@pkropachev

@prvigneshkumar92
Check the documentation for InputStream#available():
"Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream."
"The available method for class InputStream always returns 0."

Actually, available() says how many bytes can be read until read() call will block the execution.

So, just read the text from input stream.

import org.apache.commons.io.IOUtils;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Frontend extends HttpServlet {
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) {
        // TODO
    }

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //String xml = IOUtils.toString(new BufferedReader(new InputStreamReader(request.getInputStream())));
        // or
        String xml = IOUtils.toString(request.getReader());

        String responseXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
                "   <soap:Body>\n" +
                "      <m:SendNotificationResult>\n" +
                "         <m:SubscriptionStatus>OK</m:SubscriptionStatus>\n" +
                "      </m:SendNotificationResult>\n" +
                "   </soap:Body>\n" +
                "</soap:Envelope>";

        response.setContentType("text/xml");
        byte[] bytes = responseXml.getBytes("UTF-8");
        response.setContentLength(bytes.length);
        ServletOutputStream out = response.getOutputStream();
        out.write(bytes, 0, bytes.length);
        out.flush();
        out.close();
    }
}

It's better to implement the push notification listener as RESTful Web Service (JAX-RS) or SOAP Web Service (JAX-WS).
Look at Jersey, Apache CXF.

prvigneshkumar92
@prvigneshkumar92
Thank You so much Pavel (y) @pkropachev
gowtham b
@bvgpon_twitter

Hi @pkropachev

We are trying to create an appointment in EWS. The event has been created successfully.

But the timezone for the event is set as UTC and I am unable to fetch the current user's Timezone.

Is there a way to fetch the timezone of the current user ?

Kindly assist me, if there is any suggestions/workaround from your end.

Pavel Kropachev
@pkropachev
@bvgpon_twitter
As far as I know, there is no 100% solution for getting timezone of the current user. You can try some solutions from the article Finding the TimeZone being used in a Mailbox using EWS.
gowtham b
@bvgpon_twitter
Thanks @pkropachev. Will try it out.
kirit-s
@kirit-s
hi folks,
when i'm trying to create appointment using ews api and add resource using appointment.getResources().add(); method but resource is not comming in attendee's calender. pls replay fast
Pavel Kropachev
@pkropachev
@kirit-s
Check issue #698.
TimLWorkAcc
@TimLWorkAcc
Парни, кто понимает, помогите новичку... я уже весь сайт перерыл, никак не могу найти jar, а собрать его как указано на сайте через мавен не получается, какие-то пакеты не видит... задолбался уже весь :(
TimLWorkAcc
@TimLWorkAcc
Where can i download a ews-java-api.jar? I tried to make it in maven from the zip source, but I did not succeed...
medhanafi
@medhanafi
have you tried the maven dependency here https://mvnrepository.com/artifact/com.microsoft.ews-java-api/ews-java-api/2.0 ?
you can also fork the github project and add it as a module in your project and then you can access to it as local dependency
or build your own Jar
Girish Ghoda
@girishghoda57
Hi team
Can anyone help on this ticket? OfficeDev/ews-java-api#713
Philip
@philipwhiuk
Have you tried debugging to look what the actual XML response is?
The API is basically unsupported - you’ll almost certainly need to fork it to fix the problem. I was maintaining a community version at one point - I’ll try and dig that up this week.
Girish Ghoda
@girishghoda57
Any alternative API for fetch single conversation with use of id?
@philipwhiuk Thanks for reply
Philip
@philipwhiuk
Microsoft Graph maybe if it’s Exchange Online
Harshit Laddha
@iamdeadman
Hi, I am looking for a way to query for the list of all mailboxes from an exchange server with a service account from the java api library.
The service account has been given admin access to all the mailboxes already but I am not able to find any solution for how to get the list of all the mailboxes from the docs here at - https://github.com/OfficeDev/ews-java-api
I came across this SO post - https://stackoverflow.com/questions/28170508/get-mailbox-equivalent-in-ews-api
where 1 of the users answer that it is not possible while another one points me to https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.exchangeservice.getsearchablemailboxes(v=exchg.80).aspx
But I am not able to resolve / find this method in the Java API
Girish Ghoda
@girishghoda57
@philipwhiuk any update on OfficeDev/ews-java-api#713
Philip
@philipwhiuk
Kinda waiting for community response to OfficeDev/ews-java-api#692
I made a comment about how we should continue working on EWS.
Tim Pei
@timpei
Hi team, anyone ever try setting a Binary type ExtendedPropertyDefinition when sending out a message? I'm hitting a road block and not sure how to go around it. Some details here: OfficeDev/ews-java-api#714
I'm trying to set the Reply-To header of the email following Glen from this SO post: https://stackoverflow.com/questions/35988918/set-reply-to-address-in-outgoing-email-ews
Girish Ghoda
@girishghoda57

@philipwhiuk we read your comment on OfficeDev/ews-java-api#692 "If I don't get any feedback by November, I'll probably just create the org and start this process."

Can this issue OfficeDev/ews-java-api#713 not fix immediately? Our work stuck on the conversation API.

Philip
@philipwhiuk
  1. I don’t work for Microsoft at all - any EWS work I do is a hobby.
  2. Even if I did spend time to fix it for you nobody could merge it or release it.
If you’re actually blocked on it for a customer I suggest you fork the library and make the fixes yourself.
Girish Ghoda
@girishghoda57
@philipwhiuk thank you for quick answer. Actually we didn't know that you do not work for Microsoft so I mentioned you in every question.
Philip
@philipwhiuk
My understanding is @MIchaelMainer who commented on #661 here: https://github.com/OfficeDev/ews-java-api/issues/661#issuecomment-407595656 is the only Microsoft employee who has looked at the repo in the last 18 months or so.
Girish Ghoda
@girishghoda57
Ok thank you for help @philipwhiuk.
kirit7037
@kirit7037
Hi everyone, I'm trying to access other users' calendar by delegate access. but it giving some error but when I assign product license to my account it works fine but without product license, I'm not able to book meeting using EWS API
Girish Ghoda
@girishghoda57

Any help on this error:
List of possible elements expected: 'SortOrder, ParentFolderId' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages'.

SearchFilter.IsEqualTo idFilter =
new SearchFilter.IsEqualTo(ConversationSchema.Id, conversationId);
FindConversationRequest request = new FindConversationRequest(exchangeService);
request.setIndexedItemView(new ConversationIndexedItemView(1, 0, OffsetBasePoint.Beginning));
request.setConversationViewFilter(idFilter);
request.setFolderId(new FolderIdWrapper(folderId));
Collection<Conversation> singleConversation = request.execute().getConversations();

Girish Ghoda
@girishghoda57
Any help on above issue?
Girish Ghoda
@girishghoda57
Can any one answer that search filter is support in findconversation method in ews-java-api?
Its threw exception every time. I want to fetch conversation by id so I set SearchFilter.IsEqualTo(ConversationSchema.Id, conversationId); but got exception "has invalid child element 'Restriction' in namespace".
@pkropachev any suggestion?