microsoft.exchange.webservices.data.core.service.schema.EmailMessageSchema Java Examples

The following examples show how to use microsoft.exchange.webservices.data.core.service.schema.EmailMessageSchema. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExchangeMailListener.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public Message extractMessage(Item rawMessage, Map<String,Object> threadContext) throws ListenerException {
	if (!EMAIL_MESSAGE_TYPE.equals(getMessageType())) {
		return super.extractMessage(rawMessage, threadContext);
	}
	Item item = (Item) rawMessage;
	try {
		XmlBuilder emailXml = new XmlBuilder("email");
		EmailMessage emailMessage;
		PropertySet ps;
		if (isSimple()) {
			ps = new PropertySet(EmailMessageSchema.Subject);
			emailMessage = EmailMessage.bind(getFileSystem().getExchangeService(), item.getId(), ps);
			emailMessage.load();
			addEmailInfoSimple(emailMessage, emailXml);
		} else {
			ps = new PropertySet(EmailMessageSchema.DateTimeReceived, EmailMessageSchema.From, EmailMessageSchema.Subject, EmailMessageSchema.Body, EmailMessageSchema.DateTimeSent);
			emailMessage = EmailMessage.bind(getFileSystem().getExchangeService(), item.getId(), ps);
			emailMessage.load();
			addEmailInfo(emailMessage, emailXml);
		}

		if (StringUtils.isNotEmpty(getStoreEmailAsStreamInSessionKey())) {
			emailMessage.load(new PropertySet(ItemSchema.MimeContent));
			MimeContent mc = emailMessage.getMimeContent();
			ByteArrayInputStream bis = new ByteArrayInputStream(mc.getContent());
			threadContext.put(getStoreEmailAsStreamInSessionKey(), bis);
		}

		return new Message(emailXml.toXML());
	} catch (Exception e) {
		throw new ListenerException(e);
	}
}
 
Example #2
Source File: ConsumeEWS.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Fills the internal message queue if such queue is empty. This is due to
 * the fact that per single session there may be multiple messages retrieved
 * from the email server (see FETCH_SIZE).
 */
protected void fillMessageQueueIfNecessary(ProcessContext context) throws ProcessException {
    if (this.messageQueue.isEmpty()) {
        ExchangeService service = this.initializeIfNecessary(context);
        boolean deleteOnRead = context.getProperty(SHOULD_DELETE_MESSAGES).getValue().equals("true");
        boolean markAsRead = context.getProperty(SHOULD_MARK_READ).getValue().equals("true");

        try {
            //Get Folder
            Folder folder = getFolder(service);

            ItemView view = new ItemView(messageQueue.remainingCapacity());
            view.getOrderBy().add(ItemSchema.DateTimeReceived, SortDirection.Ascending);

            SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
            FindItemsResults<Item> findResults = service.findItems(folder.getId(), sf, view);

            if(findResults == null || findResults.getItems().size()== 0){
                return;
            }

            service.loadPropertiesForItems(findResults, PropertySet.FirstClassProperties);

            for (Item item : findResults) {
                EmailMessage ewsMessage = (EmailMessage) item;
                messageQueue.add(parseMessage(ewsMessage));

                if(deleteOnRead){
                    ewsMessage.delete(DeleteMode.HardDelete);
                } else if(markAsRead){
                    ewsMessage.setIsRead(true);
                    ewsMessage.update(ConflictResolutionMode.AlwaysOverwrite);
                }
            }

            service.close();
        } catch (Exception e) {
            throw new ProcessException("Failed retrieving new messages from EWS.", e);
        }
    }
}
 
Example #3
Source File: ConsumeEWS.java    From nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Fills the internal message queue if such queue is empty. This is due to
 * the fact that per single session there may be multiple messages retrieved
 * from the email server (see FETCH_SIZE).
 */
protected void fillMessageQueueIfNecessary(ProcessContext context) throws ProcessException {
    if (this.messageQueue.isEmpty()) {
        ExchangeService service = this.initializeIfNecessary(context);
        boolean deleteOnRead = context.getProperty(SHOULD_DELETE_MESSAGES).getValue().equals("true");
        boolean markAsRead = context.getProperty(SHOULD_MARK_READ).getValue().equals("true");
        String includeHeaders = context.getProperty(INCLUDE_EMAIL_HEADERS).getValue();
        String excludeHeaders = context.getProperty(EXCLUDE_EMAIL_HEADERS).getValue();

        List<String> includeHeadersList = null;
        List<String> excludeHeadersList = null;

        if (!StringUtils.isEmpty(includeHeaders)) {
            includeHeadersList = Arrays.asList(includeHeaders.split(","));
        }

        if (!StringUtils.isEmpty(excludeHeaders)) {
            excludeHeadersList = Arrays.asList(excludeHeaders.split(","));
        }

        try {
            //Get Folder
            Folder folder = getFolder(service);

            ItemView view = new ItemView(messageQueue.remainingCapacity());
            view.getOrderBy().add(ItemSchema.DateTimeReceived, SortDirection.Ascending);

            SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
            FindItemsResults<Item> findResults = service.findItems(folder.getId(), sf, view);

            if(findResults == null || findResults.getItems().size()== 0){
                return;
            }

            service.loadPropertiesForItems(findResults, PropertySet.FirstClassProperties);

            for (Item item : findResults) {
                EmailMessage ewsMessage = (EmailMessage) item;
                messageQueue.add(parseMessage(ewsMessage,includeHeadersList,excludeHeadersList));

                if(deleteOnRead){
                    ewsMessage.delete(DeleteMode.HardDelete);
                } else if(markAsRead){
                    ewsMessage.setIsRead(true);
                    ewsMessage.update(ConflictResolutionMode.AlwaysOverwrite);
                }
            }

            service.close();
        } catch (Exception e) {
            throw new ProcessException("Failed retrieving new messages from EWS.", e);
        }
    }
}
 
Example #4
Source File: ResponseMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets a list of recipients the response will be sent to.
 *
 * @return the to recipients
 * @throws Exception the exception
 */
public EmailAddressCollection getToRecipients() throws Exception {
  return (EmailAddressCollection) this
      .getObjectFromPropertyDefinition(
          EmailMessageSchema.ToRecipients);
}
 
Example #5
Source File: EmailMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets a value indicating whether a read receipt is requested for
 * the e-mail message.
 *
 * @return the checks if is read receipt requested
 * @throws ServiceLocalException the service local exception
 */
public Boolean getIsReadReceiptRequested() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.IsReadReceiptRequested);
}
 
Example #6
Source File: EmailMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets  a value indicating whether a response is requested for the
 * e-mail message.
 *
 * @return the checks if is response requested
 * @throws ServiceLocalException the service local exception
 */
public Boolean getIsResponseRequested() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.IsResponseRequested);
}
 
Example #7
Source File: EmailMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Sets the checks if is response requested.
 *
 * @param value the new checks if is response requested
 * @throws Exception the exception
 */
public void setIsResponseRequested(Boolean value) throws Exception {
  this.getPropertyBag().setObjectFromPropertyDefinition(
      EmailMessageSchema.IsResponseRequested, value);
}
 
Example #8
Source File: EmailMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets the Internat Message Id of the e-mail message.
 *
 * @return the internet message id
 * @throws ServiceLocalException the service local exception
 */
public String getInternetMessageId() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.InternetMessageId);
}
 
Example #9
Source File: EmailMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets  the references of the e-mail message.
 *
 * @return the references
 * @throws ServiceLocalException the service local exception
 */
public String getReferences() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.References);
}
 
Example #10
Source File: EmailMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Sets the references.
 *
 * @param value the new references
 * @throws Exception the exception
 */
public void setReferences(String value) throws Exception {
  this.getPropertyBag().setObjectFromPropertyDefinition(
      EmailMessageSchema.References, value);
}
 
Example #11
Source File: EmailMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets a list of e-mail addresses to which replies should be addressed.
 *
 * @return the reply to
 * @throws ServiceLocalException the service local exception
 */
public EmailAddressCollection getReplyTo() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.ReplyTo);
}
 
Example #12
Source File: EmailMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets  the sender of the e-mail message.
 *
 * @return the sender
 * @throws ServiceLocalException the service local exception
 */
public EmailAddress getSender() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.Sender);
}
 
Example #13
Source File: EmailMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Sets the sender.
 *
 * @param value the new sender
 * @throws Exception the exception
 */
public void setSender(EmailAddress value) throws Exception {
  this.getPropertyBag().setObjectFromPropertyDefinition(
      EmailMessageSchema.Sender, value);
}
 
Example #14
Source File: EmailMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets the ReceivedBy property of the e-mail message.
 *
 * @return the received by
 * @throws ServiceLocalException the service local exception
 */
public EmailAddress getReceivedBy() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.ReceivedBy);
}
 
Example #15
Source File: EmailMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets the ReceivedRepresenting property of the e-mail message.
 *
 * @return the received representing
 * @throws ServiceLocalException the service local exception
 */
public EmailAddress getReceivedRepresenting() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.ReceivedRepresenting);
}
 
Example #16
Source File: ResponseMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets a list of recipients the response will be sent to as Cc.
 *
 * @return the cc recipients
 * @throws Exception the exception
 */
public EmailAddressCollection getCcRecipients() throws Exception {
  return (EmailAddressCollection) this
      .getObjectFromPropertyDefinition(
          EmailMessageSchema.CcRecipients);
}
 
Example #17
Source File: ResponseMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets a list of recipients the response will be sent to as Cc.
 *
 * @return the bcc recipients
 * @throws Exception the exception
 */
public EmailAddressCollection getBccRecipients() throws Exception {
  return (EmailAddressCollection) this
      .getObjectFromPropertyDefinition(
          EmailMessageSchema.BccRecipients);
}
 
Example #18
Source File: ResponseMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets  the subject of this response.
 *
 * @return the subject
 * @throws Exception the exception
 */
public String getSubject() throws Exception {
  return (String) this
      .getObjectFromPropertyDefinition(EmailMessageSchema.Subject);
}
 
Example #19
Source File: ResponseMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Sets the subject.
 *
 * @param value the new subject
 * @throws Exception the exception
 */
public void setSubject(String value) throws Exception {
  this.getPropertyBag().setObjectFromPropertyDefinition(
      EmailMessageSchema.Subject, value);
}
 
Example #20
Source File: PostReply.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets the subject of the post reply.
 *
 * @return the subject
 * @throws Exception the exception
 */
public String getSubject() throws Exception {
  return (String) this
      .getObjectFromPropertyDefinition(EmailMessageSchema.Subject);
}
 
Example #21
Source File: PostReply.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Sets the subject.
 *
 * @param value the new subject
 * @throws Exception the exception
 */
public void setSubject(String value) throws Exception {
  this.getPropertyBag().setObjectFromPropertyDefinition(
      EmailMessageSchema.Subject, value);
}
 
Example #22
Source File: CalendarResponseMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets a list of recipients the response will be sent to.
 *
 * @return the to recipients
 * @throws Exception the exception
 */
public EmailAddressCollection getToRecipients() throws Exception {
  return (EmailAddressCollection) this
      .getObjectFromPropertyDefinition(
          EmailMessageSchema.ToRecipients);
}
 
Example #23
Source File: CalendarResponseMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets a list of recipients the response will be sent to as Cc.
 *
 * @return the cc recipients
 * @throws Exception the exception
 */
public EmailAddressCollection getCcRecipients() throws Exception {
  return (EmailAddressCollection) this
      .getObjectFromPropertyDefinition(
          EmailMessageSchema.CcRecipients);
}
 
Example #24
Source File: CalendarResponseMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets a list of recipients this response will be sent to as Bcc.
 *
 * @return the bcc recipients
 * @throws Exception the exception
 */
public EmailAddressCollection getBccRecipients() throws Exception {
  return (EmailAddressCollection) this
      .getObjectFromPropertyDefinition(
          EmailMessageSchema.BccRecipients);
}
 
Example #25
Source File: CalendarResponseMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets the sender of this response.
 *
 * @return the sender
 * @throws Exception the exception
 */
public EmailAddress getSender() throws Exception {
  return (EmailAddress) this
      .getObjectFromPropertyDefinition(EmailMessageSchema.Sender);
}
 
Example #26
Source File: CalendarResponseMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Sets the sender.
 *
 * @param value the new sender
 * @throws Exception the exception
 */
public void setSender(EmailAddress value) throws Exception {
  this.getPropertyBag().setObjectFromPropertyDefinition(
      EmailMessageSchema.Sender, value);
}
 
Example #27
Source File: EmailMessage.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets the list of To recipients for the e-mail message.
 *
 * @return The list of To recipients for the e-mail message.
 * @throws ServiceLocalException the service local exception
 */
public EmailAddressCollection getToRecipients()
    throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.ToRecipients);
}
 
Example #28
Source File: PostItem.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets the conversation index of the post item.
 *
 * @return the conversation index
 * @throws ServiceLocalException the service local exception
 */
public byte[] getConversationIndex() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.ConversationIndex);
}
 
Example #29
Source File: PostItem.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets the conversation topic of the post item.
 *
 * @return the conversation topic
 * @throws ServiceLocalException the service local exception
 */
public String getConversationTopic() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.ConversationTopic);
}
 
Example #30
Source File: PostItem.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets the "on behalf" poster of the post item.
 *
 * @return the from
 * @throws ServiceLocalException the service local exception
 */
public EmailAddress getFrom() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.From);
}