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


Java MailPreparationException类代码示例

本文整理汇总了Java中org.springframework.mail.MailPreparationException的典型用法代码示例。如果您正苦于以下问题:Java MailPreparationException类的具体用法?Java MailPreparationException怎么用?Java MailPreparationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: sendWithAttachment

import org.springframework.mail.MailPreparationException; //导入依赖的package包/类
@Override
public void sendWithAttachment(String to, String subject, String templateName, Map<String, String> data,
    InputStream attachment, String attachmentName) {

    try {
        File tempFile = File.createTempFile("DummyEmailService-Attachment", attachmentName);
        Files.copy(attachment, tempFile.toPath(), StandardCopyOption.REPLACE_EXISTING);

        String content = templateService.createTemplate(templateName, data);
        String attachmentNotification = "\n### ATTACHMENT: " + tempFile.getAbsolutePath() + " ###\n";

        sendMail(to, from, subject, content + attachmentNotification);
    } catch (IOException | MailPreparationException e) {
        LOG.error("Could not create dummy email from {} to {} with subject {}", from, to, subject, e);
    } finally {
        IOUtils.closeQuietly(attachment);
    }
}
 
开发者ID:Contargo,项目名称:iris,代码行数:19,代码来源:DummyEmailService.java

示例2: send

import org.springframework.mail.MailPreparationException; //导入依赖的package包/类
@Override
public void send(final MimeMessagePreparator mimeMessagePreparator) throws MailException
{
    final MimeMessage mimeMessage = createMimeMessage();
    try
    {
        mimeMessagePreparator.prepare(mimeMessage);
        final String content = (String) mimeMessage.getContent();
        final Properties javaMailProperties = getJavaMailProperties();
        javaMailProperties.setProperty("mailContent", content);
    }
    catch (final Exception e)
    {
        throw new MailPreparationException(e);
    }
}
 
开发者ID:jeffsheets,项目名称:carmaint,代码行数:17,代码来源:MockMailSender.java

示例3: send

import org.springframework.mail.MailPreparationException; //导入依赖的package包/类
@Override
public void send(final SimpleMailMessage message) throws MailException {
    try {

        final String content = message.getText();
        final Properties javaMailProperties = getJavaMailProperties();
        javaMailProperties.setProperty("mailContent", content);
    } catch (final Exception e) {
        throw new MailPreparationException(e);
    }
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:12,代码来源:MockMailSender.java

示例4: createTemplate

import org.springframework.mail.MailPreparationException; //导入依赖的package包/类
@Override
public String createTemplate(String templateName, Map<String, ?> data) {

    LOG.debug("Creating freemarker template '{}'", templateName);

    try {
        return FreeMarkerTemplateUtils.processTemplateIntoString(configuration.getTemplate(templateName), data);
    } catch (IOException | TemplateException e) {
        throw new MailPreparationException("Creating template '" + templateName + "' unsuccessful", e);
    }
}
 
开发者ID:Contargo,项目名称:iris,代码行数:12,代码来源:TemplateServiceImpl.java

示例5: send

import org.springframework.mail.MailPreparationException; //导入依赖的package包/类
@Override
public void send(final MimeMessagePreparator mimeMessagePreparator) throws MailException {
  final MimeMessage mimeMessage = createMimeMessage();
  try {
    mimeMessagePreparator.prepare(mimeMessage);
    final String content = (String) mimeMessage.getContent();
    final Properties javaMailProperties = getJavaMailProperties();
    javaMailProperties.setProperty("mailContent", content);
  } catch (final Exception e) {
    throw new MailPreparationException(e);
  }
}
 
开发者ID:geosolutions-it,项目名称:OpenSDI-Manager2,代码行数:13,代码来源:MockMailSender.java

示例6: send

import org.springframework.mail.MailPreparationException; //导入依赖的package包/类
@SuppressWarnings("OverloadedVarargsMethod")
@Override
public void send(MimeMessagePreparator... mimeMessagePreparators) throws MailException {
    MimeMessage mimeMessage = createMimeMessage();
    for (MimeMessagePreparator mimeMessagePreparator : mimeMessagePreparators) {
        try {
            mimeMessagePreparator.prepare(mimeMessage);
        } catch (Exception e) {
            throw new MailPreparationException(e);
        }
    }
    send(mimeMessage);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:14,代码来源:SimpleEmailServiceJavaMailSender.java

示例7: jobSucceedsButMailFails

import org.springframework.mail.MailPreparationException; //导入依赖的package包/类
@Test
public void jobSucceedsButMailFails()
{
	doThrow(new MailPreparationException("fail!")).when(mailSender).send(any(SimpleMailMessage.class));
	jobExecution.setProgressMessage("Job finished.");
	jobExecution.setSuccessEmail("[email protected]");
	progress.start();
	progress.success();

	Mockito.verify(mailSender).send(any(SimpleMailMessage.class));
	assertEquals(jobExecution.getProgressMessage(), "Job finished. (Mail not sent: fail!)");
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:13,代码来源:ProgressImplTest.java

示例8: jobFailsAndMailFails

import org.springframework.mail.MailPreparationException; //导入依赖的package包/类
@Test
public void jobFailsAndMailFails()
{
	doThrow(new MailPreparationException("fail!")).when(mailSender).send(any(SimpleMailMessage.class));
	jobExecution.setProgressMessage("Downloading...");
	jobExecution.setFailureEmail("[email protected]");
	progress.start();

	String exceptionMessage = "x is not a number";
	Exception ex = new IllegalArgumentException(exceptionMessage);
	progress.failed(ex);

	Mockito.verify(mailSender).send(any(SimpleMailMessage.class));
	assertEquals(jobExecution.getProgressMessage(), exceptionMessage + " (Mail not sent: fail!)");
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:16,代码来源:ProgressImplTest.java

示例9: jobCanceledAndMailFails

import org.springframework.mail.MailPreparationException; //导入依赖的package包/类
@Test
public void jobCanceledAndMailFails()
{
	doThrow(new MailPreparationException("fail!")).when(mailSender).send(any(SimpleMailMessage.class));
	jobExecution.setProgressMessage("Downloading...");
	jobExecution.setFailureEmail("[email protected]");
	progress.start();
	progress.canceled();

	Mockito.verify(mailSender).send(any(SimpleMailMessage.class));
	assertEquals(jobExecution.getProgressMessage(), "Downloading... (Mail not sent: fail!)");
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:13,代码来源:ProgressImplTest.java


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