private Folder getRecursiveFolder( String foldername ) throws MessagingException { Folder dfolder; String[] folderparts = foldername.split( "/" ); dfolder = this.getStore().getDefaultFolder(); // Open destination folder for ( int i = 0; i < folderparts.length; i++ ) { dfolder = dfolder.getFolder( folderparts[i] ); } return dfolder; }
public Mconn( LogChannelInterface log ) throws KettleException, MessagingException { super( log, MailConnectionMeta.PROTOCOL_IMAP, "junit", 0, "junit", "junit", false, false, "junit" ); store = Mockito.mock( Store.class ); inbox = Mockito.mock( Folder.class ); a = Mockito.mock( Folder.class ); b = Mockito.mock( Folder.class ); c = Mockito.mock( Folder.class ); when( a.getFullName() ).thenReturn( "A" ); when( b.getFullName() ).thenReturn( "B" ); when( c.getFullName() ).thenReturn( "C" ); when( a.exists() ).thenReturn( true ); when( b.exists() ).thenReturn( true ); when( c.exists() ).thenReturn( cCreated ); when( c.create( Mockito.anyInt() ) ).thenAnswer( new Answer<Boolean>() { @Override public Boolean answer( InvocationOnMock invocation ) throws Throwable { Object arg0 = invocation.getArguments()[0]; mode = Integer.class.cast( arg0 ); cCreated = true; return true; } } ); when( inbox.getFolder( "a" ) ).thenReturn( a ); when( a.getFolder( "b" ) ).thenReturn( b ); when( b.getFolder( "c" ) ).thenReturn( c ); when( store.getDefaultFolder() ).thenReturn( inbox ); }
public Folder openMailFolder( Store store ) throws MessagingException { Folder folder = store.getDefaultFolder(); folder = folder.getFolder( "inbox" ); folder.open( Folder.READ_ONLY ); return folder; }
/** * Set destination folder * * @param foldername * destination foldername * @param createFolder * flag create folder if needed * @throws KettleException */ public void setDestinationFolder( String foldername, boolean createFolder ) throws KettleException { try { String[] folderparts = foldername.split( "/" ); Folder f = this.getStore().getDefaultFolder(); // Open destination folder for ( int i = 0; i < folderparts.length; i++ ) { f = f.getFolder( folderparts[i] ); if ( !f.exists() ) { if ( createFolder ) { // Create folder f.create( Folder.HOLDS_MESSAGES ); } else { throw new KettleException( BaseMessages.getString( PKG, "MailConnection.Error.FolderNotFound", foldername ) ); } } } this.destinationIMAPFolder = f; } catch ( Exception e ) { throw new KettleException( e ); } }
Folder newFolder = parent.getFolder(folderName); isCreated = newFolder.create(Folder.HOLDS_MESSAGES); System.out.println("created: " + isCreated);
/** * {@inheritDoc} */ public Folder getFolder(String name) throws MessagingException { return getDefaultFolder().getFolder(name); }
/** * @see javax.mail.Store#getFolder(java.lang.String) */ public Folder getFolder(String name) throws MessagingException { return getDefaultFolder().getFolder(name); }
/** * @see javax.mail.Store#getFolder(java.lang.String) */ public Folder getFolder(String name) throws MessagingException { return getDefaultFolder().getFolder(name); }
/** * Return the Folder corresponding to the given name. * The folder might not physically exist; the {@link Folder#exists()} method can be used * to determine if it is real. * * @param name the name of the Folder to return * * @return the corresponding folder * @throws MessagingException * if there was a problem accessing the store */ public Folder getFolder(String name) throws MessagingException { return getDefaultFolder().getFolder(name); }
Folder folder = store.getDefaultFolder(); folder = folder.getFolder("INBOX"); folder.open(Folder.READ_WRITE);
/** * Return the Folder corresponding to the given name. * The folder might not physically exist; the {@link Folder#exists()} method can be used * to determine if it is real. * * @param name the name of the Folder to return * * @return the corresponding folder * @throws MessagingException * if there was a problem accessing the store */ public Folder getFolder(String name) throws MessagingException { return getDefaultFolder().getFolder(name); }
/** * Return the folder identified by the URLName; the URLName must refer to this Store. * Implementations may use the {@link URLName#getFile()} method to determined the folder name. * * @param url * * @return the corresponding folder * @throws MessagingException * if there was a problem accessing the store */ public Folder getFolder(URLName url) throws MessagingException { return getDefaultFolder().getFolder(url.getFile()); }
// Load mail properties Properties mailProperties = System.getProperties(); mailProperties.put("mail.mime.base64.ignoreerrors", "true"); mailProperties.put("mail.imaps.partialfetch", "false"); // Connect to Gmail Session session = Session.getInstance(mailProperties, null); store = session.getStore("imaps"); store.connect("imap.gmail.com", -1, "username", "password"); // Access label folder Folder defaultFolder = store.getDefaultFolder(); Folder labelFolder = defaultFolder.getFolder("mylabel"); labelFolder.open(Folder.READ_WRITE); Message[] messages = labelFolder.getMessages(); saveAttachments(messages);
/** * * @see javax.mail.Store#getFolder(javax.mail.URLName) */ public Folder getFolder(URLName url) throws MessagingException { return getDefaultFolder().getFolder(url.getFile()); }
/** * * @see javax.mail.Store#getFolder(javax.mail.URLName) */ public Folder getFolder(URLName url) throws MessagingException { return getDefaultFolder().getFolder(url.getFile()); }
/** * {@inheritDoc} */ public Folder getFolder(URLName url) throws MessagingException { return getDefaultFolder().getFolder(url.getFile()); }
@Override public JavaxMailFolder getFolder(String name) throws RuntimeMessagingException { try { return new JavaxMailFolder(delegate.getFolder(name)); } catch (MessagingException e) { throw new RuntimeMessagingException(e); } }
/** * Return the folder identified by the URLName; the URLName must refer to this Store. * Implementations may use the {@link URLName#getFile()} method to determined the folder name. * * @param url * * @return the corresponding folder * @throws MessagingException * if there was a problem accessing the store */ public Folder getFolder(URLName url) throws MessagingException { return getDefaultFolder().getFolder(url.getFile()); }
/** Builds a document collection corresponding to a given store URL and folder name. * * <p><strong>Beware.</strong> This class is not suited for large mbox files! * * @param storeUrl the javamail URL of the store. * @param folderName the folder name. * @param factory the factory that will be used to create documents. * @throws MessagingException */ protected JavamailDocumentCollection( final String storeUrl, final String folderName, final JavamailDocumentFactory factory ) throws MessagingException { this.storeUrl = storeUrl; this.folderName = folderName; this.factory = factory; this.store = SESSION.getStore( new URLName( storeUrl ) ); store.connect(); this.folder = store.getDefaultFolder().getFolder( folderName ); folder.open( Folder.READ_ONLY ); this.numberOfMessages = folder.getMessageCount(); }
/** * Establish connection with mail store and return the configured mail folder. * * @param mailParms * @param mailStore * @return the folder specified in configuration * @throws MessagingException */ private Folder retrieveMailFolder(final MailTransportParameters mailParms, final Store mailStore) throws MessagingException { mailStore.connect(mailParms.getReadTestHost(), mailParms.getReadTestPort(), mailParms.getReadTestUserName(), mailParms.getReadTestPassword()); Folder mailFolder = mailStore.getDefaultFolder(); mailFolder = mailFolder.getFolder(mailParms.getReadTestFolder()); return mailFolder; }