既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
目录
如何用java mail 实现Exchange发邮件的功能
1. 官方指导文章
官方文章:https://github.com/OfficeDev/ews-java-api/wiki/Getting-Started-Guide
Creating a Recurring Appointment
To schedule a recurring appointment, create an appointment for the first meeting time, and choose ‘Recurrence.’ Outlook will use your initial appointment as a start date. Set the end date by specifying a date for the recurring appointments to end or a number of occurrences for this recurring appointment. You can also specify no end date. If the meeting will occur on more than one day of the week, choose the days on which the meeting/appointment will occur. You can use the EWS JAVA API to create a recurring appointment, as shown in the following code.
Appointment appointment = new Appointment(service);
appointment.setSubject("Recurrence Appointment for JAVA XML TEST");
appointment.setBody(MessageBody.getMessageBodyFromText("Recurrence Test Body Msg"));
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startDate = formatter.parse("2010-05-22 12:00:00");
Date endDate = formatter.parse("2010-05-22 13:00:00");
appointment.setStart(startDate);//new Date(2010-1900,5-1,20,20,00));
appointment.setEnd(endDate); //new Date(2010-1900,5-1,20,21,00));
formatter = new SimpleDateFormat("yyyy-MM-dd");
Date recurrenceEndDate = formatter.parse("2010-07-20");
appointment.setRecurrence(new Recurrence.DailyPattern(appointment.getStart(), 3));
appointment.getRecurrence().setStartDate(appointment.getStart());
appointment.getRecurrence().setEndDate(recurrenceEndDate);
appointment.save();
Availability Service
The EWS Java API makes it very easy to consume the Availability service. The Availability service makes it possible to retrieve free/busy information for users for whom the caller does not necessarily have access rights. It also provides meeting time suggestions.
The following example shows how to call the Availability service by using the EWS Java API.
// Create a list of attendees for which to request availability
// information and meeting time suggestions.
List<AttendeeInfo> attendees = new ArrayList<AttendeeInfo>();
attendees.add(new AttendeeInfo("test@contoso.com"));
attendees.add(new AttendeeInfo("temp@contoso.com"));
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
//minimum time frame allowed by API is 24 hours
Date start = formatter.parse("2010/05/18");
Date end = formatter.parse("2010/05/19");
// Call the availability service.
GetUserAvailabilityResults results = service.getUserAvailability(
attendees,
new TimeWindow(start, end),
AvailabilityData.FreeBusyAndSuggestions);
// Output attendee availability information.
int attendeeIndex = 0;
for (AttendeeAvailability attendeeAvailability : results.getAttendeesAvailability()) {
System.out.println("Availability for " + attendees.get(attendeeIndex));
if (attendeeAvailability.getErrorCode() == ServiceError.NoError) {
for (CalendarEvent calendarEvent : attendeeAvailability.getCalendarEvents()) {
System.out.println("Calendar event");
System.out.println(" Start time: " + calendarEvent.getStartTime().toString());
System.out.println(" End time: " + calendarEvent.getEndTime().toString());
if (calendarEvent.getDetails() != null)
{
System.out.println(" Subject: " + calendarEvent.getDetails().getSubject());
// Output additional properties.
}
}
}
attendeeIndex++;
}
// Output suggested meeting times.
for (Suggestion suggestion : results.getSuggestions()) {
System.out.println("Suggested day: " + suggestion.getDate().toString());
System.out.println("Overall quality of the suggested day: " + suggestion.getQuality().toString());
for (TimeSuggestion timeSuggestion : suggestion.getTimeSuggestions()) {
System.out.println(" Suggested time: " + timeSuggestion.getMeetingTime().toString());
System.out.println(" Suggested time quality: " + timeSuggestion.getQuality().toString());
// Output additonal properties.
}
}
Using pull notifications with the EWS JAVA API
The following example shows how to subscribe to pull notifications and how to retrieve the latest events.
// Subscribe to pull notifications in the Inbox folder, and get notified when a new mail is received, when an item or folder is created, or when an item or folder is deleted.
List folder = new ArrayList();
folder.add(new FolderId().getFolderIdFromWellKnownFolderName(WellKnownFolderName.Inbox));
PullSubscription subscription = service.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.NewMail, EventType.Created, EventType.Deleted);
// Wait a couple minutes, then poll the server for new events.
GetEventsResults events = subscription.getEvents();
// Loop through all item-related events.
for(ItemEvent itemEvent : events.getItemEvents()) {
if (itemEvent.getEventType()== EventType.NewMail) {
EmailMessage message = EmailMessage.bind(service, itemEvent.getItemId());
} else if(itemEvent.getEventType()==EventType.Created) {
Item item = Item.bind(service, itemEvent.getItemId());
} else if(itemEvent.getEventType()==EventType.Deleted) {
break;
}
}
// Loop through all folder-related events.
for (FolderEvent folderEvent : events.getFolderEvents()) {
if (folderEvent.getEventType()==EventType.Created) {
Folder folder = Folder.bind(service, folderEvent.getFolderId());
} else if(folderEvent.getEventType()==EventType.Deleted) {
System.out.println("folder deleted”+ folderEvent.getFolderId.UniqueId);
}
}
如果你不想看上面的文章,可以直接跳过到下面
2. 需要用到com.microsoft.ews-java-api
microsoft.exchange.webservices
导入ews-java-api-2.0.jar, 在pom.xml文件里加入以下代码:
2.1 maven中添加
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!**
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新