List of usage examples for javax.mail Header getValue
public String getValue()
From source file:com.adaptris.core.services.splitter.MimePartSplitter.java
private void copyHeaders(MimeBodyPart src, AdaptrisMessage dest) throws MessagingException { if (preserveHeaders()) { Enumeration e = src.getAllHeaders(); while (e.hasMoreElements()) { Header h = (Header) e.nextElement(); dest.addMetadata(defaultIfEmpty(getHeaderPrefix(), "") + h.getName(), h.getValue()); }/*w w w.j a v a 2s . c om*/ } }
From source file:com.spartasystems.holdmail.smtp.SMTPHandler.java
protected MessageHeaders getHeaders(MimeMessage message) throws MessagingException { Map<String, String> headerMap = new HashMap<>(); // oh wow 2015 and it's untyped and uses Enumeration Enumeration allHeaders = message.getAllHeaders(); while (allHeaders.hasMoreElements()) { Header header = (Header) allHeaders.nextElement(); String headerName = header.getName(); String headerVal = header.getValue(); headerMap.put(headerName, headerVal); }/*from w w w . j av a 2 s .c o m*/ return new MessageHeaders(headerMap); }
From source file:com.adaptris.http.HttpHeaders.java
/** Add all the header elements to this set of headers. * <p>Any existing headers will be replaced. * /*from w w w .j a va 2 s . c o m*/ * @param other the HttpHeaders object containing the headers to be added. */ public void putAll(HttpHeaders other) { Enumeration e = other.getAllHeaders(); while (e.hasMoreElements()) { Header h = (Header) e.nextElement(); this.put(h.getName(), h.getValue()); } }
From source file:com.adaptris.core.services.mime.MimePartSelector.java
private void addHeadersAsMetadata(Enumeration e, String prefix, AdaptrisMessage msg) throws Exception { while (e.hasMoreElements()) { Header hdr = (Header) e.nextElement(); msg.addMetadata(prefix + hdr.getName(), hdr.getValue()); }/*from ww w . jav a 2 s . c om*/ }
From source file:com.cubusmail.gwtui.server.services.ShowMessageSourceServlet.java
/** * @param msg/* w w w . j a v a 2s .c om*/ * @return */ @SuppressWarnings("unchecked") private String generateHeader(Message msg) { StringBuffer headerString = new StringBuffer(); try { Enumeration<Header> e = msg.getAllHeaders(); if (e != null) { for (; e.hasMoreElements();) { Header header = e.nextElement(); headerString.append(header.getName()); headerString.append(": "); headerString.append(header.getValue()); headerString.append('\n'); } } } catch (MessagingException e) { logger.error(e.getMessage(), e); } return headerString.toString(); }
From source file:com.cubusmail.server.services.ShowMessageSourceServlet.java
/** * @param msg//from ww w. ja va 2s.c om * @return */ @SuppressWarnings("unchecked") private String generateHeader(Message msg) { StringBuffer headerString = new StringBuffer(); try { Enumeration<Header> e = msg.getAllHeaders(); if (e != null) { for (; e.hasMoreElements();) { Header header = e.nextElement(); headerString.append(header.getName()); headerString.append(": "); headerString.append(header.getValue()); headerString.append('\n'); } } } catch (MessagingException e) { log.error(e.getMessage(), e); } return headerString.toString(); }
From source file:com.adaptris.core.services.mime.FlattenMimeParts.java
private void addHeaders(InternetHeaders hdrs, MultiPartOutput out) { Enumeration e = hdrs.getAllHeaders(); while (e.hasMoreElements()) { Header h = (Header) e.nextElement(); if (!DISCARD.contains(h.getName().toLowerCase())) { out.setHeader(h.getName(), h.getValue()); }/*from w w w . java 2s . co m*/ } }
From source file:com.trsst.server.AbstractMultipartAdapter.java
private Map<String, String> getHeaders(MultipartInputStream multipart) throws IOException, MessagingException { Map<String, String> mapHeaders = new HashMap<String, String>(); moveToHeaders(multipart);/*w w w. ja v a2s . c om*/ InternetHeaders headers = new InternetHeaders(multipart); Enumeration<Header> allHeaders = headers.getAllHeaders(); if (allHeaders != null) { while (allHeaders.hasMoreElements()) { Header header = allHeaders.nextElement(); mapHeaders.put(header.getName().toLowerCase(), header.getValue()); } } return mapHeaders; }
From source file:com.garethahealy.elasticpostman.scraper.entities.EmailContent.java
public void parse() throws Exception { Session session = Session.getDefaultInstance(new Properties()); MimeMessage message = MimeMessageUtils.createMimeMessage(session, raw); MimeMessageParser mimeMessageParser = new MimeMessageParser(message); MimeMessageParser parsed = mimeMessageParser.parse(); this.from = parsed.getFrom(); this.subject = parsed.getSubject(); this.content = parsed.getPlainContent(); this.contentIds = parsed.getContentIds(); this.sentDate = new DateTime(parsed.getMimeMessage().getSentDate()); this.headers = new HashMap<String, String>(); @SuppressWarnings("unchecked") EnumerationIterator it = new EnumerationIterator(parsed.getMimeMessage().getAllHeaders()); while (it.hasNext()) { Object current = it.next(); if (current instanceof Header) { Header header = (Header) current; if (includeHeader(header.getName())) { headers.put(header.getName(), sanatizeValue(header.getName(), header.getValue())); }/*from w w w .j av a 2s. c o m*/ } } }
From source file:com.jlgranda.fede.ejb.mail.reader.EmailHelper.java
/** * get the full Mail from a message/* w w w . j a v a 2 s . c o m*/ * * @param message * @return * @throws MessagingException * @throws IOException */ public String fullMail(javax.mail.Message message) throws MessagingException, IOException { StringBuffer sBuf = new StringBuffer(); @SuppressWarnings("unchecked") Enumeration<javax.mail.Header> headers = message.getAllHeaders(); while (headers.hasMoreElements()) { javax.mail.Header header = headers.nextElement(); sBuf.append(header.getName()).append(": ").append(header.getValue()).append("\n"); } sBuf.append(fromInputStream(message.getInputStream())); return sBuf.toString(); }