本文整理汇总了Java中com.liferay.portal.kernel.mail.MailMessage类的典型用法代码示例。如果您正苦于以下问题:Java MailMessage类的具体用法?Java MailMessage怎么用?Java MailMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MailMessage类属于com.liferay.portal.kernel.mail包,在下文中一共展示了MailMessage类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: send
import com.liferay.portal.kernel.mail.MailMessage; //导入依赖的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.portal.kernel.mail.MailMessage; //导入依赖的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.portal.kernel.mail.MailMessage; //导入依赖的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: sendMail
import com.liferay.portal.kernel.mail.MailMessage; //导入依赖的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
示例5: sendMail
import com.liferay.portal.kernel.mail.MailMessage; //导入依赖的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
示例6: send
import com.liferay.portal.kernel.mail.MailMessage; //导入依赖的package包/类
public static void send(MailMessage mailMessage)
throws MailEngineException {
send(
mailMessage.getFrom(), mailMessage.getTo(), mailMessage.getCC(),
mailMessage.getBCC(), mailMessage.getBulkAddresses(),
mailMessage.getSubject(), mailMessage.getBody(),
mailMessage.isHTMLFormat(), mailMessage.getReplyTo(),
mailMessage.getMessageId(), mailMessage.getInReplyTo(),
mailMessage.getFileAttachments(), mailMessage.getSMTPAccount());
}
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:12,代码来源:MailEngine.java
示例7: sendEmail
import com.liferay.portal.kernel.mail.MailMessage; //导入依赖的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.portal.kernel.mail.MailMessage; //导入依赖的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.portal.kernel.mail.MailMessage; //导入依赖的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
示例10: execute
import com.liferay.portal.kernel.mail.MailMessage; //导入依赖的package包/类
public ActionForward execute(
ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response)
throws Exception {
String remoteUserId = request.getRemoteUser();
System.out.println("remoteUserId:"+remoteUserId);
if (remoteUserId!=null && !remoteUserId.isEmpty()){
RelInfraForm dForm=(RelInfraForm)form;
System.out.println("MMM:"+dForm.getInfrastoAdd());
ScenariosUtil.addInfras(dForm.getInfrastoAdd(), new Integer(remoteUserId), new Integer(dForm.getId()));
try {
String fromEmail = "[email protected]";
String fromName = "The Infinity Project Team";
String message = "New Scenario.";
String subject = "SCENARIO";
MailMessage mail = new MailMessage();
mail.setFrom(new InternetAddress(fromEmail, fromName));
mail.setCC(new InternetAddress(fromEmail, fromName));
mail.setTo(new InternetAddress("[email protected]",
"The Infinity Project Team"));
System.out.println(message);
mail.setBody(message);
mail.setHTMLFormat(true);
System.out.println(subject);
mail.setSubject(subject);
MailEngine.send(mail);
} catch (Exception ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
}
ScenarioForm sForm=new ScenarioForm();
Scenarios s=ScenariosUtil.getScenario(new Integer(remoteUserId),new Integer(dForm.getId()),Util.checkIfUserIsAdmin(remoteUserId));
sForm.setScenario(s);
try {
String[] coord = GoogleUtil.localize(s.getLoc());
sForm.setLatitude(coord[0]);
sForm.setLongitude(coord[1]);
} catch (Exception e) {
// TODO: handle exception
}
request.setAttribute("scenarioForm", sForm);
}
return mapping.findForward("portlet.scenario.detail");
}
开发者ID:SmartInfrastructures,项目名称:xipi,代码行数:55,代码来源:SaveInfraScenarioAction.java
注:本文中的com.liferay.portal.kernel.mail.MailMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论