gpt4 book ai didi

java - 使用 EWS Java API 检索预约的账单信息

转载 作者:行者123 更新时间:2023-12-01 15:10:11 29 4
gpt4 key购买 nike

我有账单信息中的信息,我想使用 EWS Java API 进行检索。这是我到目前为止所拥有的

public List<String> findAppointments() throws Exception
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startDate1 = formatter.parse("2012-08-26 12:00:00");
Date endDate1 = formatter.parse("2012-10-06 13:00:00");
ExchangeService service = createService();
CalendarFolder cf = CalendarFolder.bind(service, WellKnownFolderName.Calendar);
FindItemsResults<Appointment> findResults = cf.findAppointments(new CalendarView(startDate1, endDate1));
List<String> calList = new ArrayList<String>();

ExtendedPropertyDefinition BillingInfo = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Common, "34101" , MapiPropertyType.String );
PropertySet propertySet = new PropertySet(BasePropertySet.FirstClassProperties, BillingInfo);

for (Appointment appt : findResults.getItems()) {
appt = (Appointment)Item.bind(service, new ItemId(appt.getId()), propertySet);
for(ExtendedProperty extendedProperty : appt.getExtendedProperties()) {
System.out.println("extendedProperty :" + extendedProperty.getValue());
}
}
}

我在将约会项目绑定(bind)到属性集时陷入困境。

最佳答案

有任务获得相同的属性(property)。下面是另一个 API 的示例,但逻辑应该是相同的:

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.independentsoft.exchange.And;
import com.independentsoft.exchange.Appointment;
import com.independentsoft.exchange.AppointmentPropertyPath;
import com.independentsoft.exchange.FindItemResponse;
import com.independentsoft.exchange.IsGreaterThanOrEqualTo;
import com.independentsoft.exchange.IsLessThanOrEqualTo;
import com.independentsoft.exchange.ItemShape;
import com.independentsoft.exchange.MapiPropertyType;
import com.independentsoft.exchange.PropertyId;
import com.independentsoft.exchange.Service;
import com.independentsoft.exchange.ServiceException;
import com.independentsoft.exchange.StandardFolder;
import com.independentsoft.exchange.StandardPropertySet;

public class Test {

public static void main(String[] args)
{
try
{
Service service = new Service("https://myserver/ews/Exchange.asmx", "username", "password");

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startTime = dateFormat.parse("2012-09-15 00:00:00");
Date endTime = dateFormat.parse("2012-09-16 00:00:00");

IsGreaterThanOrEqualTo restriction1 = new IsGreaterThanOrEqualTo(AppointmentPropertyPath.START_TIME, startTime);
IsLessThanOrEqualTo restriction2 = new IsLessThanOrEqualTo(AppointmentPropertyPath.END_TIME, endTime);
And restriction3 = new And(restriction1, restriction2);

PropertyId billingInformationPropertyId = new PropertyId(0x8535, StandardPropertySet.COMMON, MapiPropertyType.STRING);

ItemShape shape = new ItemShape(AppointmentPropertyPath.getAllPropertyPaths());
shape.getPropertyPaths().add(billingInformationPropertyId);

FindItemResponse response = service.findItem(StandardFolder.CALENDAR, shape, restriction3);

for (int i = 0; i < response.getItems().size(); i++)
{
if (response.getItems().get(i) instanceof Appointment)
{
Appointment appointment = (Appointment) response.getItems().get(i);

System.out.println("Subject = " + appointment.getSubject());
System.out.println("StartTime = " + appointment.getStartTime());
System.out.println("EndTime = " + appointment.getEndTime());

if (appointment.getExtendedProperty(billingInformationPropertyId) != null)
{
System.out.println("Billing Information = " + appointment.getExtendedProperty(billingInformationPropertyId).getValue());
}
}
}
}
catch (ServiceException e)
{
System.out.println(e.getMessage());
System.out.println(e.getXmlMessage());

e.printStackTrace();
}
catch (ParseException e)
{
e.printStackTrace();
}
}
}

关于java - 使用 EWS Java API 检索预约的账单信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12432563/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com