Example usage for javax.mail Header getValue

List of usage examples for javax.mail Header getValue

Introduction

In this page you can find the example usage for javax.mail Header getValue.

Prototype

public String getValue() 

Source Link

Document

Returns the value of this header.

Usage

From source file:org.mule.transport.email.MailMuleMessageFactory.java

protected void addAttachmentHeaders(String name, Part part, MuleMessage muleMessage)
        throws javax.mail.MessagingException {
    Map<String, String> headers = new HashMap<String, String>();
    for (Enumeration<?> e = part.getAllHeaders(); e.hasMoreElements();) {
        Header h = (Header) e.nextElement();
        headers.put(h.getName(), h.getValue());
    }//from  www.j  a  v a2 s . c  o m

    if (headers.size() > 0) {
        muleMessage.setProperty(name + AbstractMailConnector.ATTACHMENT_HEADERS_PROPERTY_POSTFIX, headers,
                PropertyScope.INBOUND);
    }
}

From source file:org.openhim.mediator.normalization.XDSbMimeProcessorActor.java

private Enumeration createCopyOfHeaders(BodyPart part) throws MessagingException {
    Enumeration headers = part.getAllHeaders();
    InternetHeaders internetHeaders = new InternetHeaders();
    while (headers.hasMoreElements()) {
        Header header = (Header) headers.nextElement();
        internetHeaders.addHeader(header.getName(), header.getValue());
    }//  w w w . j a  v  a 2  s  .  com
    return internetHeaders.getAllHeaders();
}

From source file:org.openhim.mediator.normalization.XDSbMimeProcessorActor.java

private void copyHeadersToPart(Enumeration headers, BodyPart part) throws MessagingException {
    while (headers.hasMoreElements()) {
        Header header = (Header) headers.nextElement();
        part.setHeader(header.getName(), header.getValue());
    }// w w w  .  ja  va2s .  co m
}

From source file:org.pentaho.di.trans.steps.mailinput.ParseMailInputTest.java

@Before
public void beforeTest() throws MessagingException, IOException, KettleException {
    message = Mockito.mock(Message.class);

    MailConnection conn = mock(MailConnection.class);
    when(conn.getMessageBody(any(Message.class))).thenReturn(MSG_BODY);
    when(conn.getFolderName()).thenReturn(FLD_NAME);
    when(conn.getAttachedFilesCount(any(Message.class), any(Pattern.class))).thenReturn(ATTCH_COUNT);
    when(conn.getMessageBodyContentType(any(Message.class))).thenReturn(CNTNT_TYPE);
    data = mock(MailInputData.class);
    data.mailConn = conn;/*from  www. java2s .co  m*/

    mailInput = new MailInput(stepMockHelper.stepMeta, data, 0, stepMockHelper.transMeta, stepMockHelper.trans);

    Address addrFrom1 = mock(Address.class);
    when(addrFrom1.toString()).thenReturn(FROM1);
    Address addrFrom2 = mock(Address.class);
    when(addrFrom2.toString()).thenReturn(FROM2);
    Address addrRep1 = mock(Address.class);
    when(addrRep1.toString()).thenReturn(REP1);
    Address addrRep2 = mock(Address.class);
    when(addrRep2.toString()).thenReturn(REP2);
    Address allRec1 = mock(Address.class);
    when(allRec1.toString()).thenReturn(REC1);
    Address allRec2 = mock(Address.class);
    when(allRec2.toString()).thenReturn(REC2);

    Address[] adrFr = { addrFrom1, addrFrom2 };
    Address[] adrRep = { addrRep1, addrRep2 };
    Address[] adrRecip = { allRec1, allRec2 };

    message = Mockito.mock(Message.class);
    when(message.getMessageNumber()).thenReturn(MSG_NUMB);
    when(message.getSubject()).thenReturn(SUBJ);

    when(message.getFrom()).thenReturn(adrFr);
    when(message.getReplyTo()).thenReturn(adrRep);
    when(message.getAllRecipients()).thenReturn(adrRecip);
    when(message.getDescription()).thenReturn(DESC);
    when(message.getReceivedDate()).thenReturn(DATE1);
    when(message.getSentDate()).thenReturn(DATE2);
    when(message.getContentType()).thenReturn(CNTNT_TYPE_EMAIL);
    when(message.getSize()).thenReturn(CNTNT_SIZE);

    Header ex1 = new Header(HDR_EX1, HDR_EX1V);
    Header ex2 = new Header(HDR_EX2, HDR_EX2V);

    // for fixed [PDI-6532]
    when(message.getMatchingHeaders(aryEq(new String[] { HDR_EX1 }))).thenReturn(getEnum(new Header[] { ex1 }));
    when(message.getMatchingHeaders(aryEq(new String[] { HDR_EX2 }))).thenReturn(getEnum(new Header[] { ex2 }));
    when(message.getMatchingHeaders(aryEq(new String[] { HDR_EX1, HDR_EX2 })))
            .thenReturn(getEnum(new Header[] { ex1, ex2 }));

    // for previous implementation
    when(message.getHeader(eq(HDR_EX1))).thenReturn(new String[] { ex1.getValue() });
    when(message.getHeader(eq(HDR_EX2))).thenReturn(new String[] { ex2.getValue() });
}

From source file:org.sakaiproject.nakamura.smtp.SakaiSmtpServer.java

@SuppressWarnings("unchecked")
private void writePartPropertiesToNode(BodyPart part, Content childNode) throws MessagingException {
    Enumeration<Header> headers = part.getAllHeaders();
    while (headers.hasMoreElements()) {
        Header header = headers.nextElement();
        childNode.setProperty(header.getName(), header.getValue());
    }//from w  w  w.j  a  va2  s.c om
}

From source file:org.simplejavamail.internal.util.MimeMessageParser.java

private void extractCustomUserHeaders(final MimePart part) throws MessagingException {
    final Enumeration e = part.getAllHeaders();
    while (e.hasMoreElements()) {
        final Object headerObj = e.nextElement();
        if (headerObj instanceof Header) {
            final Header header = (Header) headerObj;
            if (isCustomUserHeader(header)) {
                headers.put(header.getName(), header.getValue());
            }/*from w w w . j  ava 2s  .  c  om*/
        }
    }
}

From source file:org.socraticgrid.displaymaildata.DisplayMailDataHandler.java

/**
 * Prints all header attributes in a Msg
 * @param msgs//from   ww w .j av  a 2 s.  c o m
 */
void printEmailMsg(Message msg) throws MessagingException {
    Enumeration headers = msg.getAllHeaders();
    while (headers.hasMoreElements()) {
        Header h = (Header) headers.nextElement();
        System.out.println(h.getName() + ": " + h.getValue());
    }
}

From source file:org.sourceforge.net.javamail4ews.transport.EwsTransport.java

@SuppressWarnings("unchecked")
private String getFirstHeaderValue(BodyPart part, String pKey) throws MessagingException {
    Enumeration<Header> lMatchingHeaders = part.getMatchingHeaders(new String[] { pKey });

    if (lMatchingHeaders.hasMoreElements()) {
        Header lHeader = lMatchingHeaders.nextElement();
        String lValue = lHeader.getValue();

        return lValue;
    }// www . j a  v a  2 s.  co m
    return null;
}