Search in sources :

Example 1 with PropertySet

use of microsoft.exchange.webservices.data.core.PropertySet in project iaf by ibissource.

the class ExchangeMailListener method getStringFromRawMessage.

public String getStringFromRawMessage(Object rawMessage, Map threadContext) throws ListenerException {
    Item item = (Item) rawMessage;
    try {
        XmlBuilder emailXml = new XmlBuilder("email");
        EmailMessage emailMessage;
        PropertySet ps;
        if (isSimple()) {
            ps = new PropertySet(EmailMessageSchema.Subject);
            emailMessage = EmailMessage.bind(exchangeService, item.getId(), ps);
            addEmailInfoSimple(emailMessage, emailXml);
        } else {
            ps = new PropertySet(EmailMessageSchema.DateTimeReceived, EmailMessageSchema.From, EmailMessageSchema.Subject, EmailMessageSchema.Body, EmailMessageSchema.DateTimeSent);
            emailMessage = EmailMessage.bind(exchangeService, item.getId(), ps);
            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 emailXml.toXML();
    } catch (Exception e) {
        throw new ListenerException(e);
    }
}
Also used : Item(microsoft.exchange.webservices.data.core.service.item.Item) EmailMessage(microsoft.exchange.webservices.data.core.service.item.EmailMessage) ListenerException(nl.nn.adapterframework.core.ListenerException) ByteArrayInputStream(java.io.ByteArrayInputStream) MimeContent(microsoft.exchange.webservices.data.property.complex.MimeContent) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) PropertySet(microsoft.exchange.webservices.data.core.PropertySet) ServiceLocalException(microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException) ListenerException(nl.nn.adapterframework.core.ListenerException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 PropertySet (microsoft.exchange.webservices.data.core.PropertySet)1 ServiceLocalException (microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException)1 EmailMessage (microsoft.exchange.webservices.data.core.service.item.EmailMessage)1 Item (microsoft.exchange.webservices.data.core.service.item.Item)1 MimeContent (microsoft.exchange.webservices.data.property.complex.MimeContent)1 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)1 ListenerException (nl.nn.adapterframework.core.ListenerException)1 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)1