Java Reference
In-Depth Information
Adding a Subject to the Message
MMS messages, like e-mail, can contain a subject header. There are two methods for working
with subjects:
public String getSubject();
public void setSubject(String subject);
Working with Other Message Headers
Depending on the MMS implementation that you work on, there might be other header infor-
mation that can be accessed. Consult JSR 205 for more details. The methods that access other
headers are as follows:
public String getHeader(String headerField);
public void setHeader(String headerField, String headerValue);
Managing Message Parts
The payload of a multipart message is the collection of contained message parts. You can
obtain any message part of a multipart message via its content ID:
public MessagePart getMessagePart(String contentID);
All the message parts of a multipart message can be obtained at once, as an array, using
this code:
public MessagePart [] getMessageParts();
To delete a message part from a message, you can use any of the following:
public boolean removeMessagePart(MessagePart part);
public boolean removeMessagePartId(String contented);
public boolean removeMessagePartLocation(String contentLocation);
The first form is convenient if you already have a copy of the message part. Otherwise, if you
have the content ID or the content location, you can use the other two variations to delete the
message part.
Adding Message Parts to a Message
When sending messages, you must first use a MessageConnection to create a new multipart
message. Next, you will follow these steps:
Create a new message part using the newMessage() class factory.
1.
2.
Set the message part's headers.
3.
Populate the message part's content.
4.
Add the part to the multipart message.
5.
Repeat 1 to 4 for all the message parts.
Search WWH ::




Custom Search