FileDocCategorySizeDatePackage
MessageTestUtils.javaAPI DocAndroid 1.5 API10517Wed May 06 22:42:46 BST 2009com.android.email.mail

MessageTestUtils

public class MessageTestUtils extends Object
Utility class makes it easier for developer to build mail message objects.

Typical usage of these helper functions and builder objects are as follows.

String text2 = new TextBuilder("").text("")
.text("").cidImg("contetid@domain").text("").build("").text("")
.text("").uriImg(contentUri).text("").build("

Fields Summary
Constructors Summary
Methods Summary
public static BodyPartbodyPart(java.lang.String mimeType, java.lang.String contentId)
Create simple MimeBodyPart.

param
mimeType MIME type of body part
param
contentId content-id header value (optional - null for no header)
return
MimeBodyPart object which body is null.
throws
MessagingException

        final MimeBodyPart bp = new MimeBodyPart(null, mimeType);
        if (contentId != null) {
            bp.setHeader(MimeHeader.HEADER_CONTENT_ID, contentId);
        }
        return bp;
    
public static android.net.UricontentUri(long attachmentId, com.android.email.Account account)
Generate AttachmentProvider content URI from attachment ID and Account.

param
attachmentId attachment id
param
account Account object
return
AttachmentProvider content URI

        return AttachmentProvider.getAttachmentUri(account, attachmentId);
    
public static BodyPartimagePart(java.lang.String mimeType, java.lang.String contentId, long attachmentId, com.android.email.mail.store.LocalStore store)
Create attachment BodyPart with content-id.

param
mimeType MIME type of image body
param
contentId content-id header value (optional - null for no header)
param
attachmentId attachment id of store
param
store LocalStore which stores attachment
return
LocalAttachmentBodyPart with content-id
throws
MessagingException
throws
IOException

        final BinaryTempFileBody imageBody = new BinaryTempFileBody();
        final LocalStore.LocalAttachmentBodyPart imagePart =
            store.new LocalAttachmentBodyPart(imageBody, attachmentId);
        imagePart.setHeader(MimeHeader.HEADER_CONTENT_TYPE, mimeType);
        if (contentId != null) {
            imagePart.setHeader(MimeHeader.HEADER_CONTENT_ID, contentId);
        }
        return imagePart;
    
public static BodyParttextPart(java.lang.String mimeType, java.lang.String text)
Create MimeBodyPart with TextBody.

param
mimeType MIME type of text
param
text body text string
return
MimeBodyPart object whose body is TextBody
throws
MessagingException

        final TextBody textBody = new TextBody(text);
        final MimeBodyPart textPart = new MimeBodyPart(textBody);
        textPart.setHeader(MimeHeader.HEADER_CONTENT_TYPE, mimeType);
        return textPart;