本文整理汇总了Java中javax.mail.internet.MimeMessage.getRecipients方法的典型用法代码示例。如果您正苦于以下问题:Java MimeMessage.getRecipients方法的具体用法?Java MimeMessage.getRecipients怎么用?Java MimeMessage.getRecipients使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.mail.internet.MimeMessage
的用法示例。
在下文中一共展示了MimeMessage.getRecipients方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSendingToCarbonCopy
import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
/**
* Test for CC / BCC
* @throws Exception
*/
@Test
public void testSendingToCarbonCopy() throws IOException, MessagingException
{
// PARAM_TO variant
Action mailAction = ACTION_SERVICE.createAction(MailActionExecuter.NAME);
mailAction.setParameterValue(MailActionExecuter.PARAM_FROM, "[email protected]");
mailAction.setParameterValue(MailActionExecuter.PARAM_TO, "[email protected]");
mailAction.setParameterValue(MailActionExecuter.PARAM_CC, "[email protected]");
mailAction.setParameterValue(MailActionExecuter.PARAM_BCC, "[email protected]");
mailAction.setParameterValue(MailActionExecuter.PARAM_SUBJECT, "Testing CARBON COPY");
mailAction.setParameterValue(MailActionExecuter.PARAM_TEMPLATE, "alfresco/templates/mail/test.txt.ftl");
mailAction.setParameterValue(MailActionExecuter.PARAM_TEMPLATE_MODEL, (Serializable) getModel());
ACTION_SERVICE.executeAction(mailAction, null);
MimeMessage message = ACTION_EXECUTER.retrieveLastTestMessage();
Assert.assertNotNull(message);
Address[] all = message.getAllRecipients();
Address[] ccs = message.getRecipients(RecipientType.CC);
Address[] bccs = message.getRecipients(RecipientType.BCC);
Assert.assertEquals(3, all.length);
Assert.assertEquals(1, ccs.length);
Assert.assertEquals(1, bccs.length);
Assert.assertTrue(ccs[0].toString().contains("some.carbon"));
Assert.assertTrue(bccs[0].toString().contains("some.blindcarbon"));
}
示例2: testSendingToArrayOfCarbonCopyAndBlindCarbonCopyUsers
import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
/**
* ALF-21948
*/
@Test
public void testSendingToArrayOfCarbonCopyAndBlindCarbonCopyUsers() throws MessagingException
{
Map<String, Serializable> params = new HashMap<String, Serializable>();
String[] ccArray = { "[email protected]", "[email protected]" };
String[] bccArray = { "[email protected]", "[email protected]", "[email protected]" };
params.put(MailActionExecuter.PARAM_FROM, "[email protected]");
params.put(MailActionExecuter.PARAM_TO, "[email protected]");
params.put(MailActionExecuter.PARAM_CC, ccArray);
params.put(MailActionExecuter.PARAM_BCC, bccArray);
params.put(MailActionExecuter.PARAM_TEXT, "Mail body here");
params.put(MailActionExecuter.PARAM_SUBJECT, "Subject text");
Action mailAction = ACTION_SERVICE.createAction(MailActionExecuter.NAME, params);
ACTION_EXECUTER.resetTestSentCount();
ACTION_SERVICE.executeAction(mailAction, null);
MimeMessage message = ACTION_EXECUTER.retrieveLastTestMessage();
Assert.assertNotNull(message);
Address[] all = message.getAllRecipients();
Address[] ccs = message.getRecipients(RecipientType.CC);
Address[] bccs = message.getRecipients(RecipientType.BCC);
Assert.assertEquals(6, all.length);
Assert.assertEquals(2, ccs.length);
Assert.assertEquals(3, bccs.length);
Assert.assertTrue(ccs[0].toString().contains("cc_user1") && ccs[1].toString().contains("cc_user2"));
Assert.assertTrue(bccs[0].toString().contains("bcc_user3") && bccs[1].toString().contains("bcc_user4")
&& bccs[2].toString().contains("bcc_user5"));
}
示例3: testSendingToListOfCarbonCopyAndBlindCarbonCopyUsers
import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
/**
* ALF-21948
*/
@Test
public void testSendingToListOfCarbonCopyAndBlindCarbonCopyUsers() throws MessagingException
{
List<String> ccList = new ArrayList<String>();
ccList.add("[email protected]");
ccList.add("[email protected]");
List<String> bccList = new ArrayList<String>();
bccList.add("[email protected]");
bccList.add("[email protected]");
bccList.add("[email protected]");
Action mailAction = ACTION_SERVICE.createAction(MailActionExecuter.NAME);
mailAction.setParameterValue(MailActionExecuter.PARAM_FROM, "[email protected]");
mailAction.setParameterValue(MailActionExecuter.PARAM_TO, "[email protected]");
mailAction.setParameterValue(MailActionExecuter.PARAM_CC, (Serializable) ccList);
mailAction.setParameterValue(MailActionExecuter.PARAM_BCC, (Serializable) bccList);
mailAction.setParameterValue(MailActionExecuter.PARAM_SUBJECT, "Testing (BLIND) CARBON COPY");
mailAction.setParameterValue(MailActionExecuter.PARAM_TEXT, "mail body here");
ACTION_EXECUTER.resetTestSentCount();
ACTION_SERVICE.executeAction(mailAction, null);
MimeMessage message = ACTION_EXECUTER.retrieveLastTestMessage();
Assert.assertNotNull(message);
Address[] all = message.getAllRecipients();
Address[] ccs = message.getRecipients(RecipientType.CC);
Address[] bccs = message.getRecipients(RecipientType.BCC);
Assert.assertEquals(6, all.length);
Assert.assertEquals(2, ccs.length);
Assert.assertEquals(3, bccs.length);
Assert.assertTrue(ccs[0].toString().contains("cc_user1") && ccs[1].toString().contains("cc_user2"));
Assert.assertTrue(bccs[0].toString().contains("bcc_user3") && bccs[1].toString().contains("bcc_user4")
&& bccs[2].toString().contains("bcc_user5"));
}
示例4: testPrepareEmailForDisabledUsers
import javax.mail.internet.MimeMessage; //导入方法依赖的package包/类
@Test
public void testPrepareEmailForDisabledUsers() throws MessagingException
{
String groupName = null;
final String USER1 = "test_user1";
final String USER2 = "test_user2";
try
{
createUser(USER1, null);
NodeRef userNode = createUser(USER2, null);
groupName = AUTHORITY_SERVICE.createAuthority(AuthorityType.GROUP, "testgroup1");
AUTHORITY_SERVICE.addAuthority(groupName, USER1);
AUTHORITY_SERVICE.addAuthority(groupName, USER2);
NODE_SERVICE.addAspect(userNode, ContentModel.ASPECT_PERSON_DISABLED, null);
final Action mailAction = ACTION_SERVICE.createAction(MailActionExecuter.NAME);
mailAction.setParameterValue(MailActionExecuter.PARAM_FROM, "[email protected]");
mailAction.setParameterValue(MailActionExecuter.PARAM_TO_MANY, groupName);
mailAction.setParameterValue(MailActionExecuter.PARAM_SUBJECT, "Testing");
mailAction.setParameterValue(MailActionExecuter.PARAM_TEXT, "Testing");
RetryingTransactionHelper txHelper = APP_CONTEXT_INIT.getApplicationContext().getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
MimeMessage mm = txHelper.doInTransaction(new RetryingTransactionCallback<MimeMessage>()
{
@Override
public MimeMessage execute() throws Throwable
{
return ACTION_EXECUTER.prepareEmail(mailAction, null, null, null).getMimeMessage();
}
}, true);
Address[] addresses = mm.getRecipients(Message.RecipientType.TO);
Assert.assertEquals(1, addresses.length);
Assert.assertEquals(USER1 + "@email.com", addresses[0].toString());
}
finally
{
if (groupName != null)
{
AUTHORITY_SERVICE.deleteAuthority(groupName, true);
}
PERSON_SERVICE.deletePerson(USER1);
PERSON_SERVICE.deletePerson(USER2);
}
}