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


Java Session.getStore方法代码示例

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


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

示例1: getEmail

import javax.mail.Session; //导入方法依赖的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: createTestMessages

import javax.mail.Session; //导入方法依赖的package包/类
public void createTestMessages() {
    try {
        GreenMailUser user = greenMail.setUser(TEST_RECIP, "password");

        final String subject = GreenMailUtil.random();
        final String body = GreenMailUtil.random();
        user.deliver(createMimeMessage("[email protected]", subject, body, null));
        user.deliver(createMimeMessage("[email protected]", "Great stuff cheap!", "body", null));
        user.deliver(createMimeMessage("[email protected]", "Happening this month", "stuff", null));
        user.deliver(createMimeMessage("[email protected]", "Get certified today!", "Cheap!", null));
        user.deliver(createMimeMessage("[email protected]", "It's been a long time!", "Let's talk", null));
        user.deliver(createMimeMessage("[email protected]", "The Sound of Drums", "boom boom boom", 
                 Date.from(LocalDate.now().minusYears(2).atStartOfDay().atZone(ZoneId.systemDefault()).toInstant())));

        Session imapSession = greenMail.getImap().createSession();
        Store store = imapSession.getStore("imap");
        store.connect(TEST_RECIP, "password");
        
        Folder defaultFolder = store.getDefaultFolder();  
        Folder inbox = store.getFolder("INBOX");
        inbox.open(Folder.READ_WRITE);
        
        Folder ads = defaultFolder.getFolder("Ads");
        ads.create(Folder.HOLDS_MESSAGES);   
        
        Folder spam = defaultFolder.getFolder("Spam");
        spam.create(Folder.HOLDS_MESSAGES); 
    } catch (MessagingException ex) {
        Logger.getLogger(TestMailUtil.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:32,代码来源:TestMailUtil.java

示例3: getStore

import javax.mail.Session; //导入方法依赖的package包/类
private Store getStore() throws MessagingException {
    if (store == null) {
        // This is the JavaMail session.
        Session session;

        // Initialize JavaMail session.
        session = Session.getDefaultInstance(new Properties(), null);

        // Connect to e-mail server
        store = session.getStore(mailProviderType);
        store.connect(mailServer, mailUser, mailPassword);
    }
    return store;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:15,代码来源:MailReader.java

示例4: login

import javax.mail.Session; //导入方法依赖的package包/类
/**
 * Process login. Connect to server and move to folder display page.
 */
public String login()
{
  try
  {
    // login to the IMAP server
    Properties props = new Properties();
    Session session = Session.getInstance(props, null);
    Store store = session.getStore("imap");
    store.connect(_server, _username, _password);
    setStore(store);

    setRootFolders(FolderData.toFolderData(this, store.getDefaultFolder().list()));

    // TODO: Add logged in indicator to restrict access

    _gotoFolder(null);

    // Set up the user's preferences;  in a real app, these would
    // be persisted somewhere.
    PreferencesData preferences = new PreferencesData();
    setPreferences(preferences);
  }
  // catch all exceptions and report them as errors
  catch (Exception e)
  {
    FacesMessage errorMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR,
                                                 e.getMessage(), null);

    FacesContext context = FacesContext.getCurrentInstance();
  context.addMessage(null, errorMessage);

    return null;
  }

  return "success";
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:40,代码来源:AccountData.java

示例5: getImapSession

import javax.mail.Session; //导入方法依赖的package包/类
private void getImapSession() throws MessagingException, NoSuchProviderException {
    Properties props = new Properties();
    props.put("mail.imap.ssl.trust", "*");
    props.put("mail.imaps.ssl.trust", "*");
    props.setProperty("mail.imap.starttls.enable", Boolean.toString(account.isUseSsl()));
    Session session = Session.getInstance(props, null);
    store = session.getStore(account.isUseSsl() ? "imaps" : "imap");
    store.connect(account.getServerName(), account.getUserName(), account.getPassword());
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:10,代码来源:AccountProcessor.java


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