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

The following examples show how to use microsoft.exchange.webservices.data.core.service.schema.EmailMessageSchema. These examples are extracted from open source projects. 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 Project: iaf   Source File: ExchangeMailListener.java    License: 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 Project: localization_nifi   Source File: ConsumeEWS.java    License: 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 Project: nifi   Source File: ConsumeEWS.java    License: 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 Project: ews-java-api   Source File: PostItem.java    License: 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 5
Source Project: ews-java-api   Source File: PostItem.java    License: 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 6
Source Project: ews-java-api   Source File: PostItem.java    License: 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);
}
 
Example 7
Source Project: ews-java-api   Source File: PostItem.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the from.
 *
 * @param value the new from
 * @throws Exception the exception
 */
public void setFrom(EmailAddress value) throws Exception {
  this.getPropertyBag().setObjectFromPropertyDefinition(
      EmailMessageSchema.From, value);
}
 
Example 8
Source Project: ews-java-api   Source File: PostItem.java    License: MIT License 2 votes vote down vote up
/**
 * Gets the Internet message Id of the post item.
 *
 * @return the internet message id
 * @throws ServiceLocalException the service local exception
 */
public String getInternetMessageId() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.InternetMessageId);
}
 
Example 9
Source Project: ews-java-api   Source File: PostItem.java    License: MIT License 2 votes vote down vote up
/**
 * Gets a value indicating whether the post item is read.
 *
 * @return the checks if is read
 * @throws ServiceLocalException the service local exception
 */
public Boolean getIsRead() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.IsRead);
}
 
Example 10
Source Project: ews-java-api   Source File: PostItem.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the checks if is read.
 *
 * @param value the new checks if is read
 * @throws Exception the exception
 */
public void setIsRead(Boolean value) throws Exception {
  this.getPropertyBag().setObjectFromPropertyDefinition(
      EmailMessageSchema.IsRead, value);
}
 
Example 11
Source Project: ews-java-api   Source File: PostItem.java    License: MIT License 2 votes vote down vote up
/**
 * Gets the references of the post item.
 *
 * @return the references
 * @throws ServiceLocalException the service local exception
 */
public String getReferences() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.References);
}
 
Example 12
Source Project: ews-java-api   Source File: PostItem.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the checks if is read.
 *
 * @param value the new checks if is read
 * @throws Exception the exception
 */
public void setIsRead(String value) throws Exception {
  this.getPropertyBag().setObjectFromPropertyDefinition(
      EmailMessageSchema.References, value);
}
 
Example 13
Source Project: ews-java-api   Source File: PostItem.java    License: MIT License 2 votes vote down vote up
/**
 * Gets the sender (poster) of the post item.
 *
 * @return the sender
 * @throws ServiceLocalException the service local exception
 */
public EmailAddress getSender() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.Sender);
}
 
Example 14
Source Project: ews-java-api   Source File: PostItem.java    License: 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 15
Source Project: ews-java-api   Source File: EmailMessage.java    License: MIT License 2 votes vote down vote up
/**
 * Method to return the schema associated with this type of object.
 *
 * @return The schema associated with this type of object.
 */
@Override public ServiceObjectSchema getSchema() {
  return EmailMessageSchema.Instance;
}
 
Example 16
Source Project: ews-java-api   Source File: EmailMessage.java    License: 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 17
Source Project: ews-java-api   Source File: EmailMessage.java    License: MIT License 2 votes vote down vote up
/**
 * Gets the list of Bcc recipients for the e-mail message.
 *
 * @return the bcc recipients
 * @throws ServiceLocalException the service local exception
 */
public EmailAddressCollection getBccRecipients()
    throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.BccRecipients);
}
 
Example 18
Source Project: ews-java-api   Source File: EmailMessage.java    License: MIT License 2 votes vote down vote up
/**
 * Gets the list of Cc recipients for the e-mail message.
 *
 * @return the cc recipients
 * @throws ServiceLocalException the service local exception
 */
public EmailAddressCollection getCcRecipients()
    throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.CcRecipients);
}
 
Example 19
Source Project: ews-java-api   Source File: EmailMessage.java    License: MIT License 2 votes vote down vote up
/**
 * Gets the conversation topic of the e-mail message.
 *
 * @return the conversation topic
 * @throws ServiceLocalException the service local exception
 */
public String getConversationTopic() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.ConversationTopic);
}
 
Example 20
Source Project: ews-java-api   Source File: EmailMessage.java    License: MIT License 2 votes vote down vote up
/**
 * Gets the conversation index of the e-mail message.
 *
 * @return the conversation index
 * @throws ServiceLocalException the service local exception
 */
public byte[] getConversationIndex() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.ConversationIndex);
}
 
Example 21
Source Project: ews-java-api   Source File: EmailMessage.java    License: MIT License 2 votes vote down vote up
/**
 * Gets  the "on behalf" sender of the e-mail message.
 *
 * @return the from
 * @throws ServiceLocalException the service local exception
 */
public EmailAddress getFrom() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.From);
}
 
Example 22
Source Project: ews-java-api   Source File: EmailMessage.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the from.
 *
 * @param value the new from
 * @throws Exception the exception
 */
public void setFrom(EmailAddress value) throws Exception {
  this.getPropertyBag().setObjectFromPropertyDefinition(
      EmailMessageSchema.From, value);
}
 
Example 23
Source Project: ews-java-api   Source File: EmailMessage.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the checks if is associated.
 *
 * @param value the new checks if is associated
 * @throws Exception the exception
 */
public void setIsAssociated(boolean value) throws Exception {
  this.getPropertyBag().setObjectFromPropertyDefinition(
      EmailMessageSchema.IsAssociated, value);
}
 
Example 24
Source Project: ews-java-api   Source File: EmailMessage.java    License: 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 delivery receipt requested
 * @throws ServiceLocalException the service local exception
 */
public Boolean getIsDeliveryReceiptRequested()
    throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.IsDeliveryReceiptRequested);
}
 
Example 25
Source Project: ews-java-api   Source File: EmailMessage.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the checks if is delivery receipt requested.
 *
 * @param value the new checks if is delivery receipt requested
 * @throws Exception the exception
 */
public void setIsDeliveryReceiptRequested(Boolean value) throws Exception {
  this.getPropertyBag().setObjectFromPropertyDefinition(
      EmailMessageSchema.IsDeliveryReceiptRequested, value);
}
 
Example 26
Source Project: ews-java-api   Source File: EmailMessage.java    License: MIT License 2 votes vote down vote up
/**
 * Gets  a value indicating whether the e-mail message is read.
 *
 * @return the checks if is read
 * @throws ServiceLocalException the service local exception
 */
public Boolean getIsRead() throws ServiceLocalException {
  return getPropertyBag().getObjectFromPropertyDefinition(
      EmailMessageSchema.IsRead);
}
 
Example 27
Source Project: ews-java-api   Source File: EmailMessage.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the checks if is read.
 *
 * @param value the new checks if is read
 * @throws Exception the exception
 */
public void setIsRead(Boolean value) throws Exception {
  this.getPropertyBag().setObjectFromPropertyDefinition(
      EmailMessageSchema.IsRead, value);
}
 
Example 28
Source Project: ews-java-api   Source File: EmailMessage.java    License: 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 29
Source Project: ews-java-api   Source File: EmailMessage.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the checks if is read receipt requested.
 *
 * @param value the new checks if is read receipt requested
 * @throws Exception the exception
 */
public void setIsReadReceiptRequested(Boolean value) throws Exception {
  this.getPropertyBag().setObjectFromPropertyDefinition(
      EmailMessageSchema.IsReadReceiptRequested, value);
}
 
Example 30
Source Project: ews-java-api   Source File: EmailMessage.java    License: 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);
}