本文整理匯總了Java中javax.mail.Folder.create方法的典型用法代碼示例。如果您正苦於以下問題:Java Folder.create方法的具體用法?Java Folder.create怎麽用?Java Folder.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.mail.Folder
的用法示例。
在下文中一共展示了Folder.create方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createTestMessages
import javax.mail.Folder; //導入方法依賴的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);
}
}
示例2: createFolder
import javax.mail.Folder; //導入方法依賴的package包/類
public void createFolder( String newFolder ){
if ( newFolder.length() == 0 )
return;
try{
Folder folderToUse = mailStore.getFolder( newFolder );
if ( !folderToUse.exists() ){
folderToUse.create( Folder.HOLDS_FOLDERS | Folder.HOLDS_MESSAGES );
}
setData( "succeeded", cfBooleanData.TRUE );
} catch (Exception E ){
setData( "errortext", new cfStringData( E.getMessage() ) );
setData( "succeeded", cfBooleanData.FALSE );
}
setTotalMessages( 0 );
}
示例3: send
import javax.mail.Folder; //導入方法依賴的package包/類
public String send()
{
Session session = _getSession();
Message msg = _setupMessage(new MimeMessage(session));
if (msg == null)
{
_LOG.info("Could not create Message object for " + getSubject());
return null;
}
try
{
Transport.send(msg);
}
catch (MessagingException me)
{
_showSendException(me);
return null;
}
_LOG.info("Sent succesfully");
try
{
Store store = _account.getStore();
// =-=AEW Hardcoding "Sent" as the folder to save "Sent" messages
Folder folder = store.getFolder("Sent");
if (folder == null)
{
// Can "folder" be null here?
throw new IllegalStateException("\"Sent\" folder was null");
}
else
{
if (!folder.exists())
folder.create(Folder.HOLDS_MESSAGES);
folder.appendMessages(new Message[]{msg});
}
}
// Need to do something better; like a "Warning: message sent, but not
// saved" message for the user?
catch (Exception e)
{
_LOG.log(Level.WARNING, "Couldn't save message in \"Sent\" folder", e);
}
return "sentMessage";
}
示例4: saveAsDraft
import javax.mail.Folder; //導入方法依賴的package包/類
public String saveAsDraft()
{
_LOG.info("Beginning send of message " + getSubject());
Session session = _getSession();
Message msg = _setupMessage(new MimeMessage(session));
if (msg == null)
{
_LOG.info("Could not create Message object for " + getSubject());
return null;
}
try
{
Store store = _account.getStore();
// =-=AEW Hardcoding "Drafts" as the folder to save drafts
Folder folder = store.getFolder("Drafts");
if (folder == null)
{
// Can "folder" be null here?
throw new IllegalStateException("\"Drafts\" folder was null");
}
else
{
if (!folder.exists())
folder.create(Folder.HOLDS_MESSAGES);
folder.appendMessages(new Message[]{msg});
}
}
// Need to do something better...
catch (Exception e)
{
_showSendException(e);
return null;
}
// And go back to the current message folder
// =-=aew Should be a "popView" thing
return "messages";
}