A java client library to access Exchange web services. The API works against Office 365 Exchange Online as well as on premises Exchange.
@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.
@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.
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.
@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.
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();
Hi all
Will EWS JAVA API work after Basic Authentication decommission?
Also, can someone please let me know on how to authenticate with OAuth 2.0 for Exchange online servers (myexchangedomain.com).