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


Java MimeMessageHelper.getMimeMessage方法代码示例

本文整理汇总了Java中org.springframework.mail.javamail.MimeMessageHelper.getMimeMessage方法的典型用法代码示例。如果您正苦于以下问题:Java MimeMessageHelper.getMimeMessage方法的具体用法?Java MimeMessageHelper.getMimeMessage怎么用?Java MimeMessageHelper.getMimeMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.mail.javamail.MimeMessageHelper的用法示例。


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

示例1: transformAndSend

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
protected void transformAndSend(InputStream template, Map<String, Object> arguments, MimeMessageHelper helper)
        throws MessagingException, IOException {

    if (!enabled) {
        log.warn("Mail message was silently consumed because mail system is disabled.");
        return;
    }

    String text = templater.transform(template, arguments);
    helper.setText(text, true);

    MimeMessage message = helper.getMimeMessage();

    if (message.getAllRecipients() != null && message.getAllRecipients().length > 0) {
        sender.send(message);
    } else {
        log.warn("Mail message was silently consumed because there were no recipients.");
    }
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:20,代码来源:MailCenter.java

示例2: createActivationMail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
/**
 * creates a activation mail.
 * 
 * may throw a RuntimeException if no MimeMessage can be created
 * 
 * @param activation {@link PendingAccountActivation}  has to contain an id and an UisUser. UisUser should contain an mail address. 
 * @return {@link MimeMessage}
 */
private MimeMessage createActivationMail(PendingAccountActivation activation) throws RuntimeException{
	log.info("creating activation mail for pending activation");
    MimeMessage mimeMsg = mailSender.createMimeMessage();
    MimeMessageHelper msg = new MimeMessageHelper(mimeMsg, "UTF-8");

    try {
        msg.setTo(activation.getForUser().getEmail());
        msg.setSubject(messages.get(MAIL_SUBJECT));
        msg.setText(messageContent(activation), true);
    } catch (MessagingException e) {
    	log.warn("activation message creation FAILED! throwing runtime-exception now");
        throw new RuntimeException(e);
    }

    return msg.getMimeMessage();
}
 
开发者ID:university-information-system,项目名称:uis,代码行数:25,代码来源:UserCreationServiceImpl.java

示例3: sendHtmlMail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
/**
 * 发送html邮件
 *
 * @throws MessagingException
 * @throws AddressException
 */
public void sendHtmlMail(String from, String[] to, String title, String text)
        throws AddressException, MessagingException {

    long start = System.currentTimeMillis();

    MimeMessage mimeMessage = mailSender.createMimeMessage();
    MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, "GBK");

    InternetAddress[] toArray = new InternetAddress[to.length];
    for (int i = 0; i < to.length; i++) {
        toArray[i] = new InternetAddress(to[i]);
    }

    messageHelper.setFrom(new InternetAddress(from));
    messageHelper.setTo(toArray);
    messageHelper.setSubject(title);
    messageHelper.setText(text, true);
    mimeMessage = messageHelper.getMimeMessage();
    mailSender.send(mimeMessage);
    long end = System.currentTimeMillis();
    LOG.info("send mail start:" + start + " end :" + end);
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:29,代码来源:MailBean.java

示例4: toMimeMessage

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
private MimeMessage toMimeMessage(final Mail mail) throws MessagingException {
    final MimeMessageHelper helper = new MimeMessageHelper(mailSender.createMimeMessage());
    helper.setTo(mail.getTo());
    helper.setFrom(mail.getFrom());
    helper.setSubject(mail.getSubject());
    helper.setText(mail.getText(), true);
    return helper.getMimeMessage();
}
 
开发者ID:music-for-all,项目名称:music-for-all-application,代码行数:9,代码来源:MailService.java

示例5: sendEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
private void sendEmail(final Action ruleAction, MimeMessageHelper preparedMessage)
{

    try
    {
        // Send the message unless we are in "testMode"
        if (!testMode)
        {	
        	mailService.send(preparedMessage.getMimeMessage());
            onSend();
        }
        else
        {
            lastTestMessage = preparedMessage.getMimeMessage();
            testSentCount++;
        }
    }
    catch (NullPointerException | MailException e)
    {
        onFail();
        String to = (String)ruleAction.getParameterValue(PARAM_TO);
        if (to == null)
        {
           Object obj = ruleAction.getParameterValue(PARAM_TO_MANY);
           if (obj != null)
           {
              to = obj.toString();
           }
        }
        
        // always log the failure
        logger.error("Failed to send email to " + to + " : " + e);
        
        // optionally ignore the throwing of the exception
        Boolean ignoreError = (Boolean)ruleAction.getParameterValue(PARAM_IGNORE_SEND_FAILURE);
        if (ignoreError == null || ignoreError.booleanValue() == false)
        {
            throw new AlfrescoRuntimeException("Failed to send email to:" + to);
        }   
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:42,代码来源:MailActionExecuter.java

示例6: sendEmail

import org.springframework.mail.javamail.MimeMessageHelper; //导入方法依赖的package包/类
private void sendEmail(final Action ruleAction, MimeMessageHelper preparedMessage)
{

    try
    {
        // Send the message unless we are in "testMode"
        if (!testMode)
        {
            mailService.send(preparedMessage.getMimeMessage());
            onSend();
        }
        else
        {
            lastTestMessage = preparedMessage.getMimeMessage();
            testSentCount++;
        }
    }
    catch (MailException e)
    {
        onFail();
        String to = (String)ruleAction.getParameterValue(PARAM_TO);
        if (to == null)
        {
           Object obj = ruleAction.getParameterValue(PARAM_TO_MANY);
           if (obj != null)
           {
              to = obj.toString();
           }
        }
        
        // always log the failure
        logger.error("Failed to send email to " + to + " : " + e);
        
        // optionally ignore the throwing of the exception
        Boolean ignoreError = (Boolean)ruleAction.getParameterValue(PARAM_IGNORE_SEND_FAILURE);
        if (ignoreError == null || ignoreError.booleanValue() == false)
        {
            throw new AlfrescoRuntimeException("Failed to send email to:" + to);
        }   
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:42,代码来源:MailActionExecuter.java


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