Methods Summary |
---|
private java.lang.String | formatAddresses(javax.mail.Address[] addrs)Utility method for formatting msg header addresses.
if (addrs == null)
return "";
StringBuffer strBuf = new StringBuffer(getDisplayAddress(addrs[0]));
for (int i = 1; i < addrs.length; i++) {
strBuf.append(", ").append(getDisplayAddress(addrs[i]));
}
return strBuf.toString();
|
public java.lang.String | getBcc()Returns the bcc field.
return formatAddresses(
message.getRecipients(Message.RecipientType.BCC));
|
public java.lang.String | getBody()Returns the body of the message (if it's plain text).
Object content = message.getContent();
if (message.isMimeType("text/plain")) {
return (String)content;
} else if (message.isMimeType("multipart/alternative")) {
Multipart mp = (Multipart)message.getContent();
int numParts = mp.getCount();
for (int i = 0; i < numParts; ++i) {
if (mp.getBodyPart(i).isMimeType("text/plain"))
return (String)mp.getBodyPart(i).getContent();
}
return "";
} else if (message.isMimeType("multipart/*")) {
Multipart mp = (Multipart)content;
if (mp.getBodyPart(0).isMimeType("text/plain"))
return (String)mp.getBodyPart(0).getContent();
else
return "";
} else
return "";
|
public java.lang.String | getCc()Returns the cc field.
return formatAddresses(
message.getRecipients(Message.RecipientType.CC));
|
public java.lang.String | getDate()Returns the date the message was sent (or received if the sent date
is null.
Date date;
SimpleDateFormat df = new SimpleDateFormat("EE M/d/yy");
if ((date = message.getSentDate()) != null)
return (df.format(date));
else if ((date = message.getReceivedDate()) != null)
return (df.format(date));
else
return "";
|
private java.lang.String | getDisplayAddress(javax.mail.Address a)Utility method which returns a string suitable for msg header display.
String pers = null;
String addr = null;
if (a instanceof InternetAddress &&
((pers = ((InternetAddress)a).getPersonal()) != null)) {
addr = pers + " "+"<"+((InternetAddress)a).getAddress()+">";
} else
addr = a.toString();
return addr;
|
public java.lang.String | getFrom()Returns the from field.
return formatAddresses(message.getFrom());
|
public Message | getMessage()Returns the javax.mail.Message object.
return message;
|
public java.lang.String | getNum()Returns the message number.
return (Integer.toString(message.getMessageNumber()));
|
public java.lang.String | getReceivedDate()Returns the received date field.
if (hasReceivedDate())
return (message.getReceivedDate().toString());
else
return "";
|
public java.lang.String | getReplyTo()Returns the address to reply to.
Address[] a = message.getReplyTo();
if (a.length > 0)
return ((InternetAddress)a[0]).getAddress();
else
return "";
|
public java.lang.String | getSentDate()Returns the sent date field.
if (hasSentDate())
return (message.getSentDate().toString());
else
return "";
|
public java.lang.String | getSubject()Returns the subject field.
if (hasSubject())
return message.getSubject();
else
return "";
|
public java.lang.String | getTo()Returns the to field.
return formatAddresses(
message.getRecipients(Message.RecipientType.TO));
|
public boolean | hasAttachments()Method for checking if the message has attachments.
boolean hasAttachments = false;
if (message.isMimeType("multipart/*")) {
Multipart mp = (Multipart)message.getContent();
if (mp.getCount() > 1)
hasAttachments = true;
}
return hasAttachments;
|
public boolean | hasBcc()Method for checking if the message has a bcc field.
return (message.getRecipients(Message.RecipientType.BCC) != null);
|
public boolean | hasCc()Method for checking if the message has a cc field.
return (message.getRecipients(Message.RecipientType.CC) != null);
|
public boolean | hasDate()Method for checking if the message has a date field.
return (hasSentDate() || hasReceivedDate());
|
public boolean | hasFrom()Method for checking if the message has a from field.
return (message.getFrom() != null);
|
public boolean | hasMimeType(java.lang.String mimeType)Method for checking if the message has the desired mime type.
return message.isMimeType(mimeType);
|
public boolean | hasReceivedDate()Method for checking if the message has a received date field.
return (message.getReceivedDate() != null);
|
public boolean | hasSentDate()Method for checking if the message has a sent date field.
return (message.getSentDate() != null);
|
public boolean | hasSubject()Method for checking if the message has a subject field.
return (message.getSubject() != null);
|
public boolean | hasTo()Method for checking if the message has a to field.
return (message.getRecipients(Message.RecipientType.TO) != null);
|
public void | setMessage(Message message)Method for mapping a message to this MessageInfo class.
this.message = message;
|