当前位置: 首页>>代码示例>>Java>>正文


Java Message.getContent方法代码示例

本文整理汇总了Java中javax.mail.Message.getContent方法的典型用法代码示例。如果您正苦于以下问题:Java Message.getContent方法的具体用法?Java Message.getContent怎么用?Java Message.getContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.mail.Message的用法示例。


在下文中一共展示了Message.getContent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEmail

import javax.mail.Message; //导入方法依赖的package包/类
public void getEmail() throws MessagingException, IOException {
    Session session = Session.getDefaultInstance(System.getProperties(),null);
    Store store = null;
    store = session.getStore("imaps");

    // store.connect(this.host, this.userName, this.password);

    // Get default folder
    Folder folder = store.getDefaultFolder();
    folder.getMessages();
    folder.getNewMessageCount();
    Message m = folder.getMessage(0);
    m.getMessageNumber();
    m.getAllRecipients();
    m.getReceivedDate();
    m.getFrom();
    m.getSubject();
    m.getReplyTo();
    m.getContent();
    m.getSize();

    // Get any folder by name
    Folder[] folderList = folder.list();
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:25,代码来源:PNetwork.java

示例2: getMessageContent

import javax.mail.Message; //导入方法依赖的package包/类
/**
 * Get the content of a mail message.
 * 
 * @param message
 *            the mail message
 * @return the content of the mail message
 */
private String getMessageContent(Message message) throws MessagingException {
    try {
        Object content = message.getContent();
        if (content instanceof Multipart) {
            StringBuffer messageContent = new StringBuffer();
            Multipart multipart = (Multipart) content;
            for (int i = 0; i < multipart.getCount(); i++) {
                Part part = multipart.getBodyPart(i);
                if (part.isMimeType("text/plain")) {
                    messageContent.append(part.getContent().toString());
                }
            }
            return messageContent.toString();
        }
        return content.toString();

    } catch (IOException e) {
        e.printStackTrace();
    }
    return "";
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:29,代码来源:MailReader.java

示例3: getAttachments

import javax.mail.Message; //导入方法依赖的package包/类
/**
 * Récupération des pièces jointe d'un mail
 * @param message Message javamail
 * @return
 * @throws Exception
 */
public static Map<String, InputStream> getAttachments(Message message) throws Exception {
    Object content = message.getContent();
    if (content instanceof String)
        return null;        

    if (content instanceof Multipart) {
        Multipart multipart = (Multipart) content;
        Map<String, InputStream> result = new HashMap<String, InputStream>();

        for (int i = 0; i < multipart.getCount(); i++) {
            result.putAll(getAttachments(multipart.getBodyPart(i)));
        }
        return result;

    }
    return null;
}
 
开发者ID:mjfcolas,项目名称:infotaf,代码行数:24,代码来源:Utils.java

示例4: getTextFromMessage

import javax.mail.Message; //导入方法依赖的package包/类
/**
 * Extracts the text content of an email message with support for multipart
 * messages
 */
private String getTextFromMessage(Message message) throws Exception {
    String result = "";
    if (message.isMimeType("multipart/*")) {
        MimeMultipart mimeMultipart = (MimeMultipart) message.getContent();
        result = getTextFromMimeMultipart(mimeMultipart);
    } else {
        Object content = message.getContent();
        result = content.toString();
    }

    return result;
}
 
开发者ID:mcdcorp,项目名称:opentest,代码行数:17,代码来源:ReadEmailImap.java

示例5: extractUrlFromMail

import javax.mail.Message; //导入方法依赖的package包/类
public static String extractUrlFromMail(Message message) throws IOException, MessagingException {
	String body = (String) message.getContent();

	Pattern pattern = Pattern.compile(".*http://localhost:8080(.*)((\r\n)|(\n)).*");
	Matcher matcher = pattern.matcher(body);

	if (matcher.find()) {
		return matcher.group(1);
	}

	return null;
}
 
开发者ID:oojorgeoo89,项目名称:QuizZz,代码行数:13,代码来源:MailHelper.java

示例6: readLatestEmailWithSubject

import javax.mail.Message; //导入方法依赖的package包/类
/**
 * Reads the latest email with the given subject from the email inbox.
 * 
 * @param subject
 *            the email subject
 * @return the email body or null if no email was found
 * @throws Exception
 */
public String readLatestEmailWithSubject(String subject) throws Exception {
    Store store = mailSession.getStore();
    store.connect();

    Folder folder = store.getFolder(MAIL_INBOX);
    folder.open(Folder.READ_WRITE);

    Message[] messages = null;

    messages = folder.search(new SubjectTerm(subject));

    String body = null;
    if (messages.length > 0) {
        Message latest = messages[0];

        for (Message m : messages) {
            if (latest.getSentDate().compareTo(m.getSentDate()) < 0) {
                latest = m;
            }
        }
        body = (String) latest.getContent();
    }

    folder.close(false);
    store.close();

    return body;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:37,代码来源:WebTester.java


注:本文中的javax.mail.Message.getContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。