Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JWebDAV for Exchange
>
Tutorial
> Create item with custom properties
The following example shows you how to create an appointment and set custom properties.
import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import com.independentsoft.webdav.exchange.Appointment; import com.independentsoft.webdav.exchange.MultiStatus; import com.independentsoft.webdav.exchange.Property; import com.independentsoft.webdav.exchange.WebdavClient; import com.independentsoft.webdav.exchange.WebdavException; public class Example { public static void main(final String[] args) { try { WebdavClient client = new WebdavClient("https://myserver/exchange/emailaddress", "username", "password"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date startDate = dateFormat.parse("2024-01-30 16:00:00"); Date endDate = dateFormat.parse("2024-01-30 18:00:00"); Appointment appointment1 = new Appointment(); appointment1.setSubject("appointment1"); appointment1.setBody("Here is body text."); appointment1.setStartDate(startDate); appointment1.setEndDate(endDate); appointment1.setRecurring(false); Property[] myProperties = new Property[3]; myProperties[0] = new Property("city", "address:", "Berlin"); myProperties[1] = new Property("street", "address:", "One Street."); myProperties[2] = new Property("number", "address:", "10"); MultiStatus multiStatus = client.createItem(appointment1, myProperties); String appointmentUrl = multiStatus.getResponses()[0].getHRef(); System.out.println("Url of just created appointment = " + appointmentUrl); } catch (WebdavException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } } }