Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
PraveenKumarKR
@PraveenKumarKR
Hi All
I wrote a code for getting OOO setting of user
code throws below error

import java.net.URI;

import microsoft.exchange.webservices.data.core.ExchangeService;
import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion;
import microsoft.exchange.webservices.data.credential.ExchangeCredentials;
import microsoft.exchange.webservices.data.credential.WebCredentials;
import microsoft.exchange.webservices.data.property.complex.availability.OofSettings;

public class GetOOO {

public static void main(String[] args)
{
try
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.setTraceEnabled(true);
service.setUrl(new URI("https://email.xxx.com/EWS/Exchange.asmx"));

      ExchangeCredentials credentials = new WebCredentials("<<superUserId>>", "<<SuperUserPassword>>","XXX");
      service.setCredentials(credentials);

      OofSettings myOOFSettings = service.getUserOofSettings("<<emailId>>");

      System.out.println(myOOFSettings.getState());


      service.close();
}
catch (Exception e)
{

    System.out.println(e.getMessage());
    e.printStackTrace();
}

}
}

Error in [GetOOOSettings.process/Java Code]While executing [invoke] encountered [microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException] : [The request failed. null at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:74)
please help
Vadik
@bboybboy
does this library work with android?
Francisco Montiel
@franciscomontiel
Hi ! is there a way to get all the emails in the conversation from a specific emailId? or is there a way to get the Convarsation Object by a ConversationId object? Thanks !
jgranduel
@jgranduel
Hi! I'm searching a way to get shared calendars. AFAIK, I need to get PR_WLINK_ENTRYID (pidtagwlinkEntryId) that I should decode from binary and then get the corresponding ewsid. If that's correct, would you mind providing a snippet? (I posted on SOF https://stackoverflow.com/questions/39920641/ews-access-shared-calendars-items-appointments, got PidtagwlinkEntryId from MFCMapi, but need to make the process automatic, preferably in Java).
mohitsoni1985
@mohitsoni1985
Hi , I want add Calendar Events into Outlook 2010 through Programatically (JAVA) how i can do that??
softashu
@softashu
Hi iis there any possibility to notify event modification in outlook exchange?
how client application get notification about event modify under exchange calendar
Magdy Abdel
@kosumosushi
Hi there, I wanted to ask if I can find a javadoc anywhere ?
lasha
@lashakv

Hi guys. Can anyone help me with a question, please? I am playing around with EWS Java Api and currently I'm trying to understand one thing.
If I loop through some items in Sent Items folder, I won't see any Emails that have: getIsFromMe() == true or getIsSubmitted() == true.
As per docs:
getIsFromMe():

  • Gets a value indicating whether the item has been sent by the current
  • authenticated user.

getIsSubmitted():

  • Gets a value indicating whether the message has been submitted to be sent.
    Aren't those values suppose to be True in Sent Items folder? If no, how can I check that Email was sent?
RimashMohomed
@RimashMohomed
@serious6 Can we use this to send email using Non-Microsoft Server?
solmaz
@soolmazr_twitter
Hi, can anyone help me please...
I have implemented a Liferay calendar portlet. I have started with ews-java-api 2.0. For testing, I gave always username/password as Hard-Code in my Code.
and Now I want to test it with signed in Liferay user. The problem is that Liferay gives me only the username and the encrypted password.
How can I do ews-authentication without forcing user to login again?
Amit Joshi
@A-Joshi
Hello
We have built a basic javax-mail provider for EWS using the EWS API and were looking to opensource it
Seemed like putting it with the ews-java api would be the best spot. Wanted to check if the OfficeDev team would be willing to host it?
retor
@retor
Hello to all. Who can explane how to subscribe to pull notifications to Calendar folder?
Jose Carlos
@josecyn

@retor I did that a while ago, but maybe it helps you.

Subscribe to pull events:

        List  folder = new ArrayList();
        folder.add(new FolderId().getFolderIdFromWellKnownFolderName(WellKnownFolderName.Calendar));

        PullSubscription subscription = ExchangeClient.getExchangeService().subscribeToPullNotifications(folder,5, /* timeOut: the subscription will end if the server is not polled within 5 minutes. */
                null, /* watermark: null to start a new subscription. */
                EventType.Created,
                EventType.Modified,
                EventType.Deleted);

        LOG.info("Subscription successful Id: ! "+subscription.getId() + " - Watermark: ! "+subscription.getWaterMark());
        LOG.info("Starting thread...");
        new Thread(new RetrieveEvents(subscription)).start();

RetrieveEvents thread:

    @Override
    public void run() {
        LOG.info("Thread started!");
        try {
            LOG.info("Sleeping...");
            sleep (60000);
            LOG.info("Awake! Let's check the events!");
            // Wait a couple minutes, then poll the server for new events.
            GetEventsResults events = subscription.getEvents();

            if (events != null && events.getItemEvents() != null && events.getAllEvents().size() > 0) {
                // Loop through all item-related events.
                for (ItemEvent itemEvent : events.getItemEvents()) {
                    LOG.info("itemEvent id: " + itemEvent.getItemId());
                }
            }
            else {
                LOG.info("No result! :(");
            }
        }
        catch (Exception e) {
            LOG.error("Exception", e);
        }
    }
retor
@retor
@josecyn thanks. Tomorrow I understand how to do it. And I do it on RxJava.
Here subscription is an object on server, what store updates and I can retrieve any updates from them.
Thanks
Sorry for my English. Yesterday not tomorrow)))))
Gervais Blaise
@gervaisb
Hello there. Sorry to disrupt but I'm wondering if there is some way to search for all Tasks in one mailbox.
I can get some tasks form the WellKnownFolerName.Tasks but I have some task created form mails but cannot find them.
Gervais Blaise
@gervaisb
At this time I'm able to get tasks from WellKnownFolderName.Tasks and I was able to get all EmailMessage from WellKnownFolderName.Inbox that have the follow-up flag via one extended property: new ExtendedPropertyDefinition(0x1090, MapiPropertyType.Integer)
Jatinder Malik
@jitu330
Hello Guys, not sure if this question has been asked before - I am trying to use this API and create a Java REST micro service using this which can work with user calendars .. but I don't want the web client to pass me users username and password and instead used windows SSO authentication and pass me the token (NTLM maybe) which I can use in microservice to connect to exchange using ews java API - do you think the same is possible? Are there any references you can point me to using which I can build this scenario locally?
amarnath111
@amarnath111
Hello Guys,
I am working on a project and need some help with the java api. I need "Add and remove email addresses from the Blocked Senders List by using EWS in Exchange" as mentioned in this link
Any idea's? Appreciate your time.
phiphuc
@phiphuc
Hello Guys
Domenic Datti
@kainazzzo
I don't know if anyone uses this room for support 😐
phiphuc
@phiphuc

hello guys, im using push notification subscribe :

System.out.println("START MAIL EXCHANGE");
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
            service.setUrl(new URI("https://outlook.office365.com/EWS/Exchange.asmx"));
            ExchangeCredentials credentials = new WebCredentials(username, passworrd, "outlook.office365.com");
            service.setCredentials(credentials);

            URI uri = new URI("http://localhost:8087/api/mail");

            WellKnownFolderName wkFolder = WellKnownFolderName.Inbox;
            FolderId folderId = new FolderId(wkFolder);
            List<FolderId> folder = new ArrayList<FolderId>();
            folder.add(folderId);
            PushSubscription subscription = service.subscribeToPushNotifications(
                folder, uri , 1, null,
                EventType.NewMail, EventType.Created, EventType.Deleted, EventType.Modified, EventType.Moved);
            /*IAsyncResult result = service.beginSubscribeToPushNotifications(null, null, folder, uri, 1, null, EventType.NewMail, EventType.Created, EventType.Deleted);
            PushSubscription subscription1 = service.endSubscribeToPushNotifications(result);*/
            System.out.println("END MAIL EXCHANGE");
        } catch (Exception e) {
            System.out.println("EXCEPTION MAIL EXCHANGE");
            e.printStackTrace();
        }

Then my Listener :
@PostMapping(value = "/mail", consumes = MediaType.TEXT_XML_VALUE)
@Timed
public void mailExchange(HttpServletRequest request, HttpServletResponse response){
log.debug("---------- MAIL_EXCHANGE_LISTERNER SUECCESS ----------");

}
i set break point in log.debug("---------- MAIL_EXCHANGE_LISTERNER SUECCESS ----------"); .when i sent email nothings happens. please help me
Pavel Kropachev
@pkropachev
@phiphuc
It's too late... But in any way, it's quite strange to wait for some events on the endpoint "localhost".
medhanafi
@medhanafi

hello guys Im new to the use of ews-java-API. when i try to get inbox folder i get this error.
microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. An element node 'soap:Envelope' of the type START_ELEMENT was expected, but node '{http://schemas.xmlsoap.org/wsdl/}definitions' of type START_ELEMENT was found.

please help me

Pavel Kropachev
@pkropachev
@medhanafi
Could you show your piece of code and SOAP request that is sent to server?
How are you setting the URL of the service?
medhanafi
@medhanafi
I try only to get inbox item count with this code
public class EwsService extends AbstractService {

    private ExchangeService service;


    public EwsService() {
            this.service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);

    }

    /**
     * Open a ews connection and return number of inbox's item
     * 
     * @return INBOX item
     * @throws Exception
     */
    public String testService() throws Exception {
        try {
            service.setCredentials(new WebCredentials("username@domain.com", "password", "domain.com"));
            service.setUrl(new URI("https://xxxxxxxxxxxxxxxxxx.com/ews/Exchange.asmx"));
            Folder inbox = new Folder(this.service);
            inbox = Folder.bind(service, WellKnownFolderName.Inbox);
            return new StringBuilder("INBOX (").append(inbox.getTotalCount()).append(")").toString();

        } catch (Exception e) {
            this.getLogger().warn("Error occured ", e);
        }
        return "{error}";
    }

}
Pavel Kropachev
@pkropachev

@medhanafi
You can join declaration and assignment for 'inbox' variable.
Use:

Folder inbox = Folder.bind(this.service, WellKnownFolderName.Inbox);

Instead of:

Folder inbox = new Folder(this.service);
inbox = Folder.bind(this.service, WellKnownFolderName.Inbox);

Your code works in my case, I use Office 365.

EwsRequest:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soap:Header>
        <t:RequestServerVersion Version="Exchange2010_SP2"/>
    </soap:Header>
    <soap:Body>
        <m:GetFolder>
            <m:FolderShape>
                <t:BaseShape>AllProperties</t:BaseShape>
            </m:FolderShape>
            <m:FolderIds>
                <t:DistinguishedFolderId Id="inbox"/>
            </m:FolderIds>
        </m:GetFolder>
    </soap:Body>
</soap:Envelope>

And EwsResponse:

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <h:ServerVersionInfo MajorBuildNumber="1294" MajorVersion="15" MinorBuildNumber="46" MinorVersion="20" Version="V2018_01_08" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
    </s:Header>
    <s:Body>
        <m:GetFolderResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <m:ResponseMessages>
                <m:GetFolderResponseMessage ResponseClass="Success">
                    <m:ResponseCode>NoError</m:ResponseCode>
                    <m:Folders>
                        <t:Folder>
                            <t:FolderId ChangeKey="AQAAABYAAABomMeTjbKLT4eZwT5LFu4VAAB18/r8" Id="AQMkADk1ZWNmODVkLWE0YmMtNGQ1Ni1hYzQ3LWYxZmFlMmFhADQ1NzYALgAAA+DspbZlAwZNth3fVoDGeR8BAGiYx5ONsotPh5nBPksW7hUAAAIBDAAAAA=="/>
                            <t:ParentFolderId ChangeKey="AQAAAA==" Id="AQMkADk1ZWNmODVkLWE0YmMtNGQ1Ni1hYzQ3LWYxZmFlMmFhADQ1NzYALgAAA+DspbZlAwZNth3fVoDGeR8BAGiYx5ONsotPh5nBPksW7hUAAAIBCAAAAA=="/>
                            <t:FolderClass>IPF.Note</t:FolderClass>
                            <t:DisplayName>Inbox</t:DisplayName>
                            <t:TotalCount>2</t:TotalCount>
                            <t:ChildFolderCount>0</t:ChildFolderCount>
                            <t:EffectiveRights>
                                <t:CreateAssociated>true</t:CreateAssociated>
                                <t:CreateContents>true</t:CreateContents>
                                <t:CreateHierarchy>true</t:CreateHierarchy>
                                <t:Delete>true</t:Delete>
                                <t:Modify>true</t:Modify>
                                <t:Read>true</t:Read>
                                <t:ViewPrivateItems>true</t:ViewPrivateItems>
                            </t:EffectiveRights>
                            <t:UnreadCount>1</t:UnreadCount>
                        </t:Folder>
                    </m:Folders>
                </m:GetFolderResponseMessage>
            </m:ResponseMessages>
        </m:GetFolderResponse>
    </s:Body>
</s:Envelope>
Do you use on-premise Exchange server? Could you capture raw SOAP?
Just add the following code before use the ExchangeService:
            this.service.setTraceEnabled(true);
            this.service.setTraceFlags(EnumSet.allOf(TraceFlags.class));
            this.service.setTraceListener(new ITraceListener() {
                public void trace(String type, String message) {
                    System.out.println("Type: " + type + "\nMessage: " + message);
                }
            });
medhanafi
@medhanafi
Hello thanks, after join declaration and assignment for 'inbox' variable and adding trace code , i got this:
Type: EwsRequestHttpHeaders
Message: <Trace Tag="EwsRequestHttpHeaders" Tid="16" Time="2018-11-19 13:15:20Z">
POST /ews/Exchange.asmx HTTP/1.1
Keep-Alive : 300
Content-type : text/xml; charset=utf-8
Accept : text/xml
User-Agent : ExchangeServicesClient/0.0.0.0
Connection : Keep-Alive
Accept-Encoding : gzip,deflate


</Trace>

Type: EwsRequest
Message: <Trace Tag="EwsRequest" Tid="16" Time="2018-11-19 13:15:20Z">
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"><soap:Header><t:RequestServerVersion Version="Exchange2010_SP2"></t:RequestServerVersion></soap:Header><soap:Body><m:GetFolder><m:FolderShape><t:BaseShape>AllProperties</t:BaseShape></m:FolderShape><m:FolderIds><t:DistinguishedFolderId Id="inbox"></t:DistinguishedFolderId></m:FolderIds></m:GetFolder></soap:Body></soap:Envelope>
</Trace>

13:15:21.153 [http-nio-8080-exec-1] WARN  c.o.s.e.a.s.EwsService - Error occured 
microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. The request failed. Certificate for <domaine.com> doesn't match any of the subject alternative names: [webmail.xxxxx.com, mail.xxxxx.com, autodiscover.xxxxx.com]
    at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:74)
and my test service
public String testService() {
        try {
            ExchangeCredentials credentials = new WebCredentials("*********@***********.com", "********!");
            credentials.preAuthenticate();
            this.service.setCredentials(credentials);
            this.service.setUrl(new URI("https://********************.com/ews/Exchange.asmx"));
            this.service.setTraceEnabled(true);
            this.service.setTraceFlags(EnumSet.allOf(TraceFlags.class));
            this.service.setTraceListener(new ITraceListener() {
                public void trace(String type, String message) {
                    System.out.println("Type: " + type + "\nMessage: " + message);
                }
            });

            Folder inbox = Folder.bind(this.service, WellKnownFolderName.Inbox);
            return new StringBuilder("INBOX (").append(inbox.getTotalCount()).append(")").toString();

        } catch (Exception e) {
            this.getLogger().warn("Error occured ", e);
        }
        return "error";
    }
Pavel Kropachev
@pkropachev
EWS SOAP request is correct.
Looks like that hostname which you use to connect to EWS is not included to certificate of your Exchange server. In the result, verification of this hostname is failed.
You can use one of the subject alternative names from certificate to connect, e.g. "https://webmail.xxxxx.com/EWS/Exchange.asmx", "https://mail.xxxxx.com/EWS/Exchange.asmx".
Or use custom service (with non-default hostname verifier) to ignore verification of hostname (in fact, allow all hosts).
https://github.com/OfficeDev/ews-java-api/wiki/Custom-Exchange-services
medhanafi
@medhanafi
Thank you now its works.
I customize the Exchange services and switch off hostname verification. So i have a question
To understand better, what is the disadvantage to override hostname verifier
Pavel Kropachev
@pkropachev
Your application will accept invalid and wildcard certificates. This may be acceptable for testing and/or usage inside intranet, but not for production and public usage. One of the way is add option in your application to ignore verification of hostname.
If you requested certificate for your Exchange server from Certificate Authority provider then just request issue a certificate with additional subject alternative names that are used by your server.
If you're using your own Certificate Services in AD then just issue a new certificate for your Exchange server.
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.