本文整理了Java中javax.mail.Message.getSubject()
方法的一些代码示例,展示了Message.getSubject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getSubject()
方法的具体详情如下:
包路径:javax.mail.Message
类名称:Message
方法名:getSubject
[英]Get the subject of this message.
[中]获取此消息的主题。
代码示例来源:origin: spring-projects/spring-integration-samples
subject = mailMessage.getSubject();
} catch (IOException e) {
throw new IllegalStateException("Error while retrieving the email contents.", e);
代码示例来源:origin: spring-projects/spring-framework
@Override
public void sendMessage(Message message, Address[] addresses) throws MessagingException {
if ("fail".equals(message.getSubject())) {
throw new MessagingException("failed");
}
if (addresses == null || (message.getAllRecipients() == null ? addresses.length > 0 :
!ObjectUtils.nullSafeEquals(addresses, message.getAllRecipients()))) {
throw new MessagingException("addresses not correct");
}
if (message.getSentDate() == null) {
throw new MessagingException("No sentDate specified");
}
if (message.getSubject() != null && message.getSubject().contains("custom")) {
assertEquals(new GregorianCalendar(2005, 3, 1).getTime(), message.getSentDate());
}
this.sentMessages.add(message);
}
}
代码示例来源:origin: apache/usergrid
public void findContent( Folder folder ) throws MessagingException, IOException {
for ( Message m : folder.getMessages() ) {
logger.info( "Subject: " + m.getSubject() );
}
}
}
代码示例来源:origin: spring-projects/spring-integration-samples
filename = bp.getFileName();
disposition = bp.getDisposition();
subject = mailMessage.getSubject();
代码示例来源:origin: pentaho/pentaho-kettle
break;
case MailInputField.COLUMN_SUBJECT:
r[index] = message.getSubject();
break;
case MailInputField.COLUMN_SENDER:
代码示例来源:origin: pentaho/pentaho-kettle
when( message.getSubject() ).thenReturn( SUBJ );
代码示例来源:origin: stackoverflow.com
for (Message message: messages) {
message.getSubject(); //-> goes to the imap server to fetch the subject line
}
代码示例来源:origin: apache/usergrid
assertEquals( "User Account Confirmation: "+email, confirmation.getSubject() );
assertEquals( "User Account Confirmed", confirmation.getSubject() );
assertEquals( "Request For Admin User Account Activation "+email, activation.getSubject() );
assertEquals( "User Account Activated", activated.getSubject() );
代码示例来源:origin: apache/usergrid
@Test
public void testCreateOrganizationAndAdminWithConfirmationOnly() throws Exception {
setup.set( PROPERTIES_SYSADMIN_APPROVES_ADMIN_USERS, "false" );
setup.set( PROPERTIES_SYSADMIN_APPROVES_ORGANIZATIONS, "false" );
setup.set( PROPERTIES_ADMIN_USERS_REQUIRE_CONFIRMATION, "true" );
setup.set( PROPERTIES_NOTIFY_ADMIN_OF_ACTIVATION, "true" );
final String orgName = uniqueOrg();
final String userName = uniqueUsername();
final String email = uniqueEmail();
OrganizationOwnerInfo org_owner =
createOwnerAndOrganization( orgName, userName, "Test User", email, "testpassword", false, false );
assertNotNull( org_owner );
List<Message> inbox = Mailbox.get( email );
assertFalse( inbox.isEmpty() );
MockImapClient client = new MockImapClient( "mockserver.com", "test-user-1", "somepassword" );
client.processMail();
Message confirmation = inbox.get( 0 );
assertEquals( "User Account Confirmation: " + email, confirmation.getSubject() );
String token = getTokenFromMessage( confirmation );
logger.info( token );
assertEquals( ActivationState.ACTIVATED,
setup.getMgmtSvc().handleConfirmationTokenForAdminUser( org_owner.owner.getUuid(), token ) );
Message activation = inbox.get( 1 );
assertEquals( "User Account Activated", activation.getSubject() );
client = new MockImapClient( "mockserver.com", "test-user-1", "somepassword" );
client.processMail();
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* The match method.
*
* @param msg the pattern match is applied to this Message's
* subject header
* @return true if the pattern match succeeds, otherwise false
*/
public boolean match(Message msg) {
String subj;
try {
subj = msg.getSubject();
} catch (Exception e) {
return false;
}
if (subj == null)
return false;
return super.match(subj);
}
代码示例来源:origin: oblac/jodd
subject(msg.getSubject());
代码示例来源:origin: apache/usergrid
assertEquals( subject, activation.getSubject() );
assertEquals( subject, reset.getSubject() );
代码示例来源:origin: oblac/jodd
@Test
void testTextHtml() throws MessagingException, IOException {
final Email email = Email.create()
.from(FROM_EXAMPLE_COM)
.to(TO_EXAMPLE_COM)
.subject(SUB)
.textMessage(HELLO)
.htmlMessage("<html><body><h1>Hey!</h1></body></html>");
final Message message = createMessage(email);
assertEquals(1, message.getFrom().length);
assertEquals(FROM_EXAMPLE_COM, message.getFrom()[0].toString());
assertEquals(1, message.getRecipients(RecipientType.TO).length);
assertEquals(TO_EXAMPLE_COM, message.getRecipients(RecipientType.TO)[0].toString());
assertEquals(SUB, message.getSubject());
// wrapper
final MimeMultipart multipart = (MimeMultipart) message.getContent();
assertEquals(1, multipart.getCount());
assertTrue(multipart.getContentType().contains("multipart/mixed"));
// inner content
final MimeBodyPart mimeBodyPart = (MimeBodyPart) multipart.getBodyPart(0);
final MimeMultipart mimeMultipart = (MimeMultipart) mimeBodyPart.getContent();
assertEquals(2, mimeMultipart.getCount());
assertTrue(mimeMultipart.getContentType().contains("multipart/alternative"));
MimeBodyPart bodyPart = (MimeBodyPart) mimeMultipart.getBodyPart(0);
assertEquals(HELLO, bodyPart.getContent());
assertTrue(bodyPart.getDataHandler().getContentType().contains(MimeTypes.MIME_TEXT_PLAIN));
bodyPart = (MimeBodyPart) mimeMultipart.getBodyPart(1);
assertEquals("<html><body><h1>Hey!</h1></body></html>", bodyPart.getContent());
assertTrue(bodyPart.getDataHandler().getContentType().contains(MimeTypes.MIME_TEXT_HTML));
}
代码示例来源:origin: apache/usergrid
assertEquals( subject, confirmation.getSubject() );
代码示例来源:origin: stackoverflow.com
inbox.open(Folder.READ_ONLY);
Message[] messages = inbox.getMessages(start + 1, total);
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
fp.add(FetchProfileItem.FLAGS);
fp.add(FetchProfileItem.CONTENT_INFO);
fp.add("X-mailer");
inbox.fetch(messages, fp); // Load the profile of the messages in 1 fetch.
for (Message message: messages) {
message.getSubject(); //Subject is already local, no additional fetch required
}
代码示例来源:origin: oblac/jodd
assertEquals(SUB, message.getSubject());
代码示例来源:origin: spring-projects/spring-integration
@Test // INT-2991 filtered messages were marked SEEN
public void receiveAndMarkAsReadDontDeleteFiltered() throws Exception {
AbstractMailReceiver receiver = new ImapMailReceiver();
Message msg1 = mock(MimeMessage.class);
Message msg2 = mock(MimeMessage.class);
given(msg2.getSubject()).willReturn("foo"); // should not be marked seen
Expression selectorExpression = new SpelExpressionParser()
.parseExpression("subject == null OR !subject.equals('foo')");
receiver.setSelectorExpression(selectorExpression);
receiver = receiveAndMarkAsReadDontDeleteGuts(receiver, msg1, msg2);
verify(msg1, times(1)).setFlag(Flag.SEEN, true);
verify(msg2, never()).setFlag(Flag.SEEN, true);
verify(receiver, times(0)).deleteMessages(Mockito.any());
}
代码示例来源:origin: webx/citrus
/** 以另一个邮件作为附件。 */
protected final void render(Part mailPart, Message mail) throws MailBuilderException {
try {
mailPart.setContent(mail, CONTENT_TYPE_MESSAGE);
String subject = mail.getSubject();
if (!StringUtil.isEmpty(subject)) {
mailPart.setDescription(MailUtil.encodeHeader(subject, getMailBuilder().getCharacterEncoding()));
}
} catch (MessagingException e) {
throw new MailBuilderException("Failed to add attachment to the mail", e);
} catch (UnsupportedEncodingException e) {
throw new MailBuilderException("Failed to add attachment to the mail", e);
}
}
代码示例来源:origin: webx/citrus
/** 以另一个邮件作为附件。 */
protected final void render(Part mailPart, Message mail) throws MailBuilderException {
try {
mailPart.setContent(mail, CONTENT_TYPE_MESSAGE);
String subject = mail.getSubject();
if (!StringUtil.isEmpty(subject)) {
mailPart.setDescription(MailUtil.encodeHeader(subject, getMailBuilder().getCharacterEncoding()));
}
} catch (MessagingException e) {
throw new MailBuilderException("Failed to add attachment to the mail", e);
} catch (UnsupportedEncodingException e) {
throw new MailBuilderException("Failed to add attachment to the mail", e);
}
}
代码示例来源:origin: pentaho/pentaho-kettle
.getMessage().getFrom()[0].toString(), "" ) ) );
logDebug( BaseMessages.getString( PKG, "JobGetMailsFromPOP.EmailSubject.Label", Const.NVL(
mailConn.getMessage().getSubject(), "" ) ) );
内容来源于网络,如有侵权,请联系作者删除!