• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MailServiceUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: send

import com.liferay.mail.service.MailServiceUtil; //导入依赖的package包/类
public static void send(String toStr, String subject,
		String body, boolean isHtml) throws SystemException, AddressException, PortalException {

	Company cmp = null;
	try {
	  cmp = CompanyServiceUtil.getCompanyByVirtualHost(AppConstants.COMPANY_VIRTUAL_HOST);
	} catch (Throwable t) {
		
	}
	if (cmp != null) {
		long cmpId = cmp.getCompanyId();
		String fromStr = PrefsPropsUtil.getString(cmpId,
				PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);
		InternetAddress from = new InternetAddress(fromStr);
		InternetAddress to = new InternetAddress(toStr);
		if (from != null && to != null && subject != null && body != null) {
			MailMessage message = new MailMessage(from, to, subject, body, isHtml);
			MailServiceUtil.sendEmail(message);
		}
	}

}
 
开发者ID:fraunhoferfokus,项目名称:govapps,代码行数:23,代码来源:MailUtil.java


示例2: sendEmailToAdministrator

import com.liferay.mail.service.MailServiceUtil; //导入依赖的package包/类
private void sendEmailToAdministrator(String screenName) {

        _log.warn(screenName);
        try {

            MailMessage mail = new MailMessage();
            mail.setFrom(new InternetAddress("[email protected]"));
            mail.setTo(new InternetAddress("[email protected]"));
            mail.setSubject("new user added");
            mail.setBody("adding new user: " + screenName);

            MailServiceUtil.sendEmail(mail);

        } catch (AddressException e) {
            _log.error("cannot send email");
        }
    }
 
开发者ID:mimacom,项目名称:maven-liferay-plugin,代码行数:18,代码来源:UserServiceImpl.java


示例3: _notityMail

import com.liferay.mail.service.MailServiceUtil; //导入依赖的package包/类
private void _notityMail(String context, Throwable e) {

		try {
			String errorMailTo =
				PrefsPropsUtil.getString(
					PortletPropsKeys.MQTT_ERRORS_SEND_MAIL_TO,
					PortletPropsValues.MQTT_ERRORS_SEND_MAIL_TO);

			if (Validator.isNotNull(errorMailTo)) {
				MailMessage mailMessage = new MailMessage();

				long companyId = PortalUtil.getDefaultCompanyId();

				String fromAddress = PrefsPropsUtil.getString(
					companyId, PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);

				mailMessage.setHTMLFormat(false);
				mailMessage.setTo(new InternetAddress(errorMailTo));
				mailMessage.setSubject(String.format(
					"%s Mqtt connector error", PortalUtil.getComputerName()));
				mailMessage.setFrom(new InternetAddress(fromAddress));

				StringWriter sw = new StringWriter();
				PrintWriter pw = new PrintWriter(sw);
				e.printStackTrace(pw);

				mailMessage.setBody(String.format(
					"context: %s\nerror: %s\n stacktrace:%s\n", context,
					e.getMessage(), sw.toString()));

				MailServiceUtil.sendEmail(mailMessage);
			}
		}
		catch (Exception e1) {
			_log.error(e1);
		}
	}
 
开发者ID:baxtheman,项目名称:mqtt-liferay-plugins,代码行数:38,代码来源:MqttLocalServiceImpl.java


示例4: getSession

import com.liferay.mail.service.MailServiceUtil; //导入依赖的package包/类
public static Session getSession(boolean cache) {
	Session session = null;

	try {
		session = MailServiceUtil.getSession();
	}
	catch (SystemException se) {
		if (_log.isWarnEnabled()) {
			_log.warn(se, se);
		}

		session = InfrastructureUtil.getMailSession();
	}

	if (_log.isDebugEnabled()) {
		session.setDebug(true);

		session.getProperties().list(System.out);
	}

	return session;
}
 
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:23,代码来源:MailEngine.java


示例5: sendMail

import com.liferay.mail.service.MailServiceUtil; //导入依赖的package包/类
public static void sendMail(String emailTo, String nameTo, String content[], long companyId, Locale userLocale) {
	
	try{
		InternetAddress to = new InternetAddress(emailTo, nameTo);
		
		String portal = LanguageUtil.get(userLocale, "p2ptaskactivity.mail.portal");
		String subject= LanguageUtil.get(userLocale, "p2ptaskactivity.mail.subject");
		
		String bodyTitle   = LanguageUtil.format(userLocale, "p2ptaskactivity.mail.body.title", nameTo);
		String bodyMessage = LanguageUtil.format(userLocale, "p2ptaskactivity.mail.body.message", content);
		String bodyEnd     = LanguageUtil.get(userLocale, "p2ptaskactivity.mail.body.end");
		
		String body = bodyTitle +"\n\n"+ bodyMessage +"\n\n"+ bodyEnd +"\n\n"+ portal+"\n";
		log.debug("MESSAGE: "+bodyMessage);
		String fromName=PrefsPropsUtil.getString(companyId,PropsKeys.ADMIN_EMAIL_FROM_NAME,"");
		String fromAddress=PrefsPropsUtil.getString(companyId,PropsKeys.ADMIN_EMAIL_FROM_ADDRESS,"");
					
		InternetAddress from = new InternetAddress(fromAddress, fromName);
		
		MailMessage mailm = new MailMessage(from, to, subject, body, true);
		MailServiceUtil.sendEmail(mailm);
	}
	catch(Exception ex)
	{
	}	

}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:28,代码来源:P2PSendMailAsignation.java


示例6: sendMail

import com.liferay.mail.service.MailServiceUtil; //导入依赖的package包/类
private void sendMail(final InternetAddress from, final InternetAddress to,
        final String subj, final String body) {
	final MailMessage msg = new MailMessage();
	msg.setHTMLFormat(true);
	msg.setFrom(from);
	msg.setTo(to);
	msg.setSubject(MessageComposer.getInstance().replaceCommon(from.toString(),
	        to.toString(), subj));
	msg.setBody(MessageComposer.getInstance().replaceCommon(from.toString(),
	        to.toString(), body));
	m_objLog.info("Sending mail from " + from + " to " + to + " about "
	        + subj);
	MailServiceUtil.sendEmail(msg);
}
 
开发者ID:fraunhoferfokus,项目名称:particity,代码行数:15,代码来源:MailListener.java


示例7: sendEmail

import com.liferay.mail.service.MailServiceUtil; //导入依赖的package包/类
private void sendEmail(String email, String subject, String body, boolean sendHtml) throws Exception {
    InternetAddress rcpt = new InternetAddress(email);
    InternetAddress from = new InternetAddress(PrefsPropsUtil.getString(LiferayUtil.getThemeDisplay().getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS));

    MailMessage mailMessage = new MailMessage();
    mailMessage.setBody(body);
    mailMessage.setHTMLFormat(sendHtml);
    mailMessage.setFrom(from);
    mailMessage.setTo(rcpt);
    mailMessage.setSubject(subject);
    MailServiceUtil.sendEmail(mailMessage);
}
 
开发者ID:wbstr,项目名称:liferay-newsletter,代码行数:13,代码来源:SubscriberEmailSender.java


示例8: sendEmail

import com.liferay.mail.service.MailServiceUtil; //导入依赖的package包/类
public void sendEmail(SendListElem rcpt, InternetAddress from, String subject, String body, boolean sendHtml) {
        try {
            logger.info("sendEmail {0} {1} {2} {3}", new Object[]{from, subject, rcpt, body});

            List<NewsletterConfig> configs = NewsletterConfigLocalServiceUtil.findByConfigKey("subscriptionActionLayout");
            NewsletterConfig subscriptionActionLayout;
            subscriptionActionLayout = configs.get(0);
            Layout layout = null;
            layout = LayoutLocalServiceUtil.getLayout(Long.parseLong(subscriptionActionLayout.getConfigValue()));
//            layout = LayoutLocalServiceUtil.getLayoutByUuidAndGroupId(subscriptionActionLayout.getConfigValue(), themeDisplay.getScopeGroupId());
//            layout = LayoutLocalServiceUtil.getLayoutByUuidAndGroupId(subscriptionActionLayout.getConfigValue(), themeDisplay.getScopeGroupId(),false);
            String layoutURL = PortalUtil.getLayoutURL(layout, themeDisplay);

            MailMessage mailMessage = new MailMessage();
            String cancLink = "";
            if (rcpt.getNewsletterSubscriptionCategory() != null) {
                cancLink = rcpt.getNewsletterSubscriptionCategory().getCancellationKey();
            }
            body = body.replace("###newsletterCategory###", rcpt.getCategoryName());
            body = body.replace("###portalUrl###", themeDisplay.getURLPortal());
            //body = body.replace("###portalUrl###", themeDisplay.getURLHome()); //web/quest is needed
            //body = body.replace("###cancelattionLink###", "subscription?"+EmailConst.Action.CANCEL_PARAM_KEY+"=" + cancLink);
            body = body.replace("###cancelattionLink###", layoutURL + "?" + EmailConst.Action.CANCEL_PARAM_KEY + "=" + cancLink);
            mailMessage.setBody(body);
            mailMessage.setHTMLFormat(sendHtml);
            mailMessage.setFrom(from);
            mailMessage.setTo(rcpt.getSubscriptionEmail());
            mailMessage.setSubject(subject);
            MailServiceUtil.sendEmail(mailMessage);
        } catch (Exception e) {
            logger.error(e);
        }
    }
 
开发者ID:wbstr,项目名称:liferay-newsletter,代码行数:34,代码来源:NewsletterSenderThread.java


示例9: sendMailP2pDone

import com.liferay.mail.service.MailServiceUtil; //导入依赖的package包/类
private static void sendMailP2pDone(User user, long actId, ThemeDisplay themeDisplay){
		try
		{
			LearningActivity activity = LearningActivityLocalServiceUtil.getLearningActivity(actId);
			
			Group group = GroupLocalServiceUtil.getGroup(activity.getGroupId());
			
			Course course= CourseLocalServiceUtil.getCourseByGroupCreatedId(activity.getGroupId());
			
			Module module = ModuleLocalServiceUtil.getModule(activity.getModuleId());
			String courseFriendlyUrl = "";
			String courseTitle = "";
			String activityTitle = activity.getTitle(user.getLocale());
			String moduleTitle =  module.getTitle(user.getLocale());
			String portalUrl = PortalUtil.getPortalURL(themeDisplay);
			String pathPublic = PortalUtil.getPathFriendlyURLPublic();
			
			//QUITANDO PUERTOS
			String[] urls = portalUrl.split(":");
			portalUrl = urls[0] + ":" +urls[1];				
//			if(urls.length > 2){ // http:prueba.es:8080
//				portalUrl += urls[1];
//			}
			_log.debug("***portalUrl:"+portalUrl);
			
					
			if(course != null){
				courseTitle = course.getTitle(user.getLocale());
				courseFriendlyUrl = portalUrl + pathPublic + course.getFriendlyURL();
				courseFriendlyUrl += "/reto?p_p_id=p2ptaskactivity_WAR_liferaylmsportlet";
				courseFriendlyUrl += "&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_r_p_564233524_actId="+actId;
				courseFriendlyUrl += "&p_r_p_564233524_moduleId="+activity.getModuleId();
				_log.debug("URL "+ courseFriendlyUrl);
			}
			
			String messageArgs[]= {activityTitle, moduleTitle, courseTitle, courseFriendlyUrl};
			String titleArgs[]= {String.valueOf(user.getFullName())};
			
			//Nuevos campos del email
			//Subject
			
			String subject = LanguageUtil.get(user.getLocale(), "p2ptaskactivity.mail.sendactivity.mail.subject"); 
			String title = LanguageUtil.format(user.getLocale(), "p2ptaskactivity.mail.sendactivity.mail.title", titleArgs);
			String body = title +"<br /><br />"+ LanguageUtil.format(user.getLocale(), "p2ptaskactivity.mail.sendactivity.mail.message", messageArgs);
			
			String firmaPortal  = PrefsPropsUtil.getString(themeDisplay.getCompanyId(),"firma.email.admin");
			// JOD
			firmaPortal = (firmaPortal!=null?firmaPortal:"");

			
			if(_log.isDebugEnabled()){_log.debug("P2PActivityPortlet::sendMailNoCorrection::subject:"+subject);}
			if(_log.isDebugEnabled()){_log.debug("P2PActivityPortlet::sendMailNoCorrection::body:"+body);}
			
			//String fromUser=PrefsPropsUtil.getString(user.getCompanyId(),PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);
			String fromName=PrefsPropsUtil.getString(user.getCompanyId(),PropsKeys.ADMIN_EMAIL_FROM_NAME,"");
			String fromAddress=PrefsPropsUtil.getString(user.getCompanyId(),PropsKeys.ADMIN_EMAIL_FROM_ADDRESS,"");
			InternetAddress from = new InternetAddress(fromAddress, fromName);
			InternetAddress to = new InternetAddress(user.getEmailAddress(), user.getFullName());
			MailMessage mailMessage = new MailMessage(from, to, subject, body, true);
			
			MailServiceUtil.sendEmail(mailMessage);		
			//MailEngine.send(from, new InternetAddress[]{to}, new InternetAddress[]{}, subject, body, true);
			if(_log.isDebugEnabled()){_log.debug("P2PActivityPortlet::sendMailNoCorrection::Mail Enviado");}
		}
		/*catch(MailEngineException ex) {
			if(_log.isErrorEnabled()){_log.error(ex);}

		}*/ catch (Exception e) {
			if(_log.isErrorEnabled()){_log.error(e);}
		}
	}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:72,代码来源:P2PActivityPortlet.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Headers类代码示例发布时间:2022-05-23
下一篇:
Java CachePoolIterator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap