none
EWS Java api 1.1 equivalent to EWS managed Api c# scheduling email delivery??? RRS feed

All replies

  • I used the following code but it doesnt work. What is wrong with the following code?

     

                EmailMessage msg=new EmailMessage(service);
                msg.setSubject("testing from exchange");
                msg.setBody(MessageBody.getMessageBodyFromText("test body"));
                msg.getToRecipients().add("valid@gmail.com");
                     
           
                ExtendedPropertyDefinition PR_DEFERRED_DELIVERY_TIME=new ExtendedPropertyDefinition(15, MapiPropertyType.SystemTime);
                String ut="2011-05-09T16:30:00Z";
               
               
                msg.setExtendedProperty(PR_DEFERRED_DELIVERY_TIME, ut);
     
           

    Monday, May 9, 2011 10:43 PM
  • I also tried the following code and get a null pointer exception.


       EmailMessage msg=new EmailMessage(service);

       msg.setBody(MessageBody.getMessageBodyFromText("hello test"));
       msg.getToRecipients().add("valid@gmail.com");
       
        
       ExtendedPropertyDefinition PR_DEFERRED_SEND_TIME=new ExtendedPropertyDefinition(16367, MapiPropertyType.SystemTime);
       ExtendedPropertyDefinition PR_DEFERRED_DELIVERY_TIME=new ExtendedPropertyDefinition(15, MapiPropertyType.SystemTime);
       String ut="2011-05-09T17:15:00Z";
       
      
       msg.setExtendedProperty(PR_DEFERRED_SEND_TIME, ut);
       msg.setExtendedProperty(PR_DEFERRED_DELIVERY_TIME, ut);
       
        
       System.out.println("done");
      

    Error message is as follows:

    Exception in thread "main" java.lang.NullPointerException
     at microsoft.exchange.webservices.data.ExtendedPropertyDefinition.isEqualTo(ExtendedPropertyDefinition.java:183)
     at microsoft.exchange.webservices.data.ExtendedPropertyDefinition.equals(ExtendedPropertyDefinition.java:304)
     at microsoft.exchange.webservices.data.ExtendedPropertyCollection.tryGetProperty(ExtendedPropertyCollection.java:168)
     at microsoft.exchange.webservices.data.ExtendedPropertyCollection.getOrAddExtendedProperty(ExtendedPropertyCollection.java:101)
     at microsoft.exchange.webservices.data.ExtendedPropertyCollection.setExtendedProperty(ExtendedPropertyCollection.java:124)
     at microsoft.exchange.webservices.data.Item.setExtendedProperty(Item.java:478)
     at MainTest.main(MainTest.java:65)

    Monday, May 9, 2011 11:06 PM
  • Hi Nondescriptive,Thanks for using Ews java api.please find the sample code for scheduling email delivery. Please find the sample code below and let us know if you are not successful.

     

    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);

                    service.setTraceEnabled(true);

                    service.setUrl(<URL>);

                    ExchangeCredentials credentials = new WebCredentials(USERNAME,PASSWORD, DOMAIN);

                    service.setCredentials(credentials);

                    EmailMessage msg = new EmailMessage(service);

                    msg.setSubject("KT");

                    msg.setBody(MessageBody.getMessageBodyFromText("Email sending from java"));

                    msg.getToRecipients().add(EMAIL_ID);

    ExtendedPropertyDefinition PR_DEFERRED_SEND_TIME=new ExtendedPropertyDefinition(16367, MapiPropertyType.SystemTime);

    ExtendedPropertyDefinition PR_DEFERRED_DELIVERY_TIME=new ExtendedPropertyDefinition(15, MapiPropertyType.SystemTime);

                    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

                    Date startDate = formatter.parse("2011-05-19 6:12:0");         

                    msg.setExtendedProperty(PR_DEFERRED_SEND_TIME, startDate);

                    msg.setExtendedProperty(PR_DEFERRED_DELIVERY_TIME, startDate);

                    msg.send();

    Friday, June 17, 2011 11:13 AM