/** * Binds to an existing e-mail message and loads its first class * property.Calling this method results in a call to EWS. * * @param service the service * @param id the id * @return An EmailMessage instance representing the e-mail message * corresponding to the specified Id * @throws Exception the exception */ public static EmailMessage bind(ExchangeService service, ItemId id) throws Exception { return EmailMessage.bind(service, id, PropertySet .getFirstClassProperties()); }
public MimeMessage parseMessage(EmailMessage item, List<String> hdrIncludeList, List<String> hdrExcludeList) throws Exception { EmailMessage ewsMessage = item; final String bodyText = ewsMessage.getBody().toString(); if(ewsMessage.getBody().getBodyType() == BodyType.HTML){ mm = new HtmlEmail(); if(!StringUtils.isEmpty(bodyText)){ mm.setFrom(ewsMessage.getFrom().getAddress()); ewsMessage.getToRecipients().forEach(x->{ try { mm.addTo(x.getAddress()); ewsMessage.getCcRecipients().forEach(x->{ try { mm.addCc(x.getAddress()); mm.setSubject(ewsMessage.getSubject()); mm.setSentDate(ewsMessage.getDateTimeSent()); ewsMessage.getInternetMessageHeaders().getItems().stream() .filter(x -> (hdrIncludeList == null || hdrIncludeList.isEmpty() || hdrIncludeList.contains(x.getName())) && (hdrExcludeList == null || hdrExcludeList.isEmpty() || !hdrExcludeList.contains(x.getName()))) if(ewsMessage.getHasAttachments()){ ewsMessage.getAttachments().forEach(x->{ try { FileAttachment file = (FileAttachment)x;
public Object createServiceObjectWithServiceParam( ExchangeService srv) throws Exception { return new EmailMessage(srv); } }, new ICreateServiceObjectWithAttachmentParam() {
this.throwIfThisIsAttachment(); if (this.isNew()) { if ((this.getAttachments().getCount() == 0) || (messageDisposition == MessageDisposition.SaveOnly)) { this.internalCreate(parentFolderId, messageDisposition, null); } else { this.internalCreate(null, // null means use the Drafts folder in this.getService().sendItem(this, parentFolderId); } else if (this.isDirty()) { this.getAttachments().validate(); this.getAttachments().save(); if (this.getPropertyBag().getIsUpdateCallNecessary()) { this.internalUpdate(parentFolderId, ConflictResolutionMode.AutoResolve, messageDisposition, null); } else { this.getService().sendItem(this, parentFolderId); this.getService().sendItem(this, parentFolderId);
private TaskDto convertToTaskDto(final EmailMessage email) throws ServiceLocalException { Integer flagValue = null; Date dueDate = null; for (final ExtendedProperty extendedProperty : email.getExtendedProperties()) { if (extendedProperty.getPropertyDefinition().getTag() != null && extendedProperty.getPropertyDefinition() .getTag() == PID_TAG_FLAG_STATUS) { flagValue = (Integer) extendedProperty.getValue(); } else if (extendedProperty.getPropertyDefinition().getId() != null && extendedProperty .getPropertyDefinition().getId() == PID_LID_TASK_DUE_DATE) { dueDate = (Date) extendedProperty.getValue(); } } final TaskDto task = new TaskDto(); task.setExchangeId(email.getId().getUniqueId()); task.setLastModified(convertToJodaDateTime(email.getLastModifiedTime())); task.setName(email.getSubject()); if (flagValue == null) { throw new RuntimeException("Found email without follow-up flag!"); } else if (flagValue == PR_FLAG_STATUS_FOLLOWUP_COMPLETE) { task.setCompleted(true); } else { LOG.debug("Found flagged email " + email.getSubject()); } task.setDueDate(convertToJodaDateTime(dueDate)); return task; }
/** * Replies to the message. Calling this method results in a call to EWS. * * @param bodyPrefix the body prefix * @param replyAll the reply all * @throws Exception the exception */ public void reply(MessageBody bodyPrefix, boolean replyAll) throws Exception { ResponseMessage responseMessage = this.createReply(replyAll); responseMessage.setBodyPrefix(bodyPrefix); responseMessage.sendAndSaveCopy(); }
/** * Forwards the message. Calling this method results in a call to EWS. * * @param bodyPrefix the body prefix * @param toRecipients the to recipients * @throws Exception the exception */ public void forward(MessageBody bodyPrefix, EmailAddress... toRecipients) throws Exception { if (null != toRecipients) { forward(bodyPrefix, Arrays.asList(toRecipients)); } }
/** * Forwards the message. Calling this method results in a call to EWS. * * @param bodyPrefix the body prefix * @param toRecipients the to recipients * @throws Exception the exception */ public void forward(MessageBody bodyPrefix, Iterable<EmailAddress> toRecipients) throws Exception { ResponseMessage responseMessage = this.createForward(); responseMessage.setBodyPrefix(bodyPrefix); responseMessage.getToRecipients() .addEmailRange(toRecipients.iterator()); responseMessage.sendAndSaveCopy(); }
this.throwIfThisIsAttachment(); if (this.isNew()) { if ((this.getAttachments().getCount() == 0) || (messageDisposition == MessageDisposition.SaveOnly)) { this.internalCreate(parentFolderId, messageDisposition, null); } else { this.internalCreate(null, // null means use the Drafts folder in this.getService().sendItem(this, parentFolderId); } else if (this.isDirty()) { this.getAttachments().validate(); this.getAttachments().save(); if (this.getPropertyBag().getIsUpdateCallNecessary()) { this.internalUpdate(parentFolderId, ConflictResolutionMode.AutoResolve, messageDisposition, null); } else { this.getService().sendItem(this, parentFolderId); this.getService().sendItem(this, parentFolderId);
/** * Replies to the message. Calling this method results in a call to EWS. * * @param bodyPrefix the body prefix * @param replyAll the reply all * @throws Exception the exception */ public void reply(MessageBody bodyPrefix, boolean replyAll) throws Exception { ResponseMessage responseMessage = this.createReply(replyAll); responseMessage.setBodyPrefix(bodyPrefix); responseMessage.sendAndSaveCopy(); }
/** * Forwards the message. Calling this method results in a call to EWS. * * @param bodyPrefix the body prefix * @param toRecipients the to recipients * @throws Exception the exception */ public void forward(MessageBody bodyPrefix, EmailAddress... toRecipients) throws Exception { if (null != toRecipients) { forward(bodyPrefix, Arrays.asList(toRecipients)); } }
/** * Forwards the message. Calling this method results in a call to EWS. * * @param bodyPrefix the body prefix * @param toRecipients the to recipients * @throws Exception the exception */ public void forward(MessageBody bodyPrefix, Iterable<EmailAddress> toRecipients) throws Exception { ResponseMessage responseMessage = this.createForward(); responseMessage.setBodyPrefix(bodyPrefix); responseMessage.getToRecipients() .addEmailRange(toRecipients.iterator()); responseMessage.sendAndSaveCopy(); }
public MimeMessage parseMessage(EmailMessage item, List<String> hdrIncludeList, List<String> hdrExcludeList) throws Exception { EmailMessage ewsMessage = item; final String bodyText = ewsMessage.getBody().toString(); if(ewsMessage.getBody().getBodyType() == BodyType.HTML){ mm = new HtmlEmail(); if(!StringUtils.isEmpty(bodyText)){ mm.setFrom(ewsMessage.getFrom().getAddress()); ewsMessage.getToRecipients().forEach(x->{ try { mm.addTo(x.getAddress()); ewsMessage.getCcRecipients().forEach(x->{ try { mm.addCc(x.getAddress()); mm.setSubject(ewsMessage.getSubject()); mm.setSentDate(ewsMessage.getDateTimeSent()); ewsMessage.getInternetMessageHeaders().getItems().stream() .filter(x -> (hdrIncludeList == null || hdrIncludeList.isEmpty() || hdrIncludeList.contains(x.getName())) && (hdrExcludeList == null || hdrExcludeList.isEmpty() || !hdrExcludeList.contains(x.getName()))) if(ewsMessage.getHasAttachments()){ ewsMessage.getAttachments().forEach(x->{ try { FileAttachment file = (FileAttachment)x;
/** * Binds to an existing e-mail message and loads its first class * property.Calling this method results in a call to EWS. * * @param service the service * @param id the id * @return An EmailMessage instance representing the e-mail message * corresponding to the specified Id * @throws Exception the exception */ public static EmailMessage bind(ExchangeService service, ItemId id) throws Exception { return EmailMessage.bind(service, id, PropertySet .getFirstClassProperties()); }
public Object createServiceObjectWithAttachmentParam( ItemAttachment itemAttachment, boolean isNew) throws Exception { return new EmailMessage(itemAttachment); } });
id = item.getId(); message = new EmailMessage(mService); message.bind(mService, id); } catch (ServiceLocalException e) { e.printStackTrace();
public Object createServiceObjectWithServiceParam( ExchangeService srv) throws Exception { return new EmailMessage(srv); } }, new ICreateServiceObjectWithAttachmentParam() {
public Object createServiceObjectWithAttachmentParam( ItemAttachment itemAttachment, boolean isNew) throws Exception { return new EmailMessage(itemAttachment); } });