Mail utils

The IMailUtils help to manage mails.

Mail templates

Since Process2024.1.0 Process integrates an email template management system in the “Platform management” application.

A utility class allows you to manipulate these templates by calling the SDKFactory.

Bookmarks

Bookmark Description
${iUser} The full name of the user who will receive the mail
${link} The link used by the mail’s button (if the button is used)
${directLinkLabel} The label used under the button to introduce the direct link
${details} A custom section to display some details (usually in a grey section)
${serverBaseURL} The server base URL
${subject} The mail’s subject, automatically loaded in the template
${content} The mail’s content, automatically loaded in the template
${logo} The logo’s link, automatically loaded in the template
${primaryColor} The main color, automatically loaded in the template
${linkLabel} The button’s label, automatically loaded in the template
${footerText} The footer’s text, automatically loaded in the template

Examples

Find a template

import com.axemble.vdoc.sdk.SDKFactory;

public class MyClass {
	
	private void myFunction() {
		IResource myMailTemplate = SDKFactory.UTILS.getMailUtils().retrieveMailTemplateFromReference(myContext, "my_template_reference");
	}
}

Build a mail from a template

import com.axemble.vdoc.sdk.SDKFactory;
import com.axemble.vdoc.sdk.system.mail.beans.IMailTemplate;

public class MyClass {
	
	private void myFunction(IResource myMailTemplate) {
		// Parameters to replace the bookmarks
		Map<String, Object> parameters = new HashMap<>();
		parameters.put("iUser", "myUserName");
		IMailTemplate mailTemplate = SDKFactory.UTILS.getMailUtils().buildMailTemplate("fr", myMailTemplate, parameters);
		// You can get the full email content with mailTemplate.getFullMail();
	}
}

Send a mail

import com.axemble.vdoc.sdk.modules.IBasePortalModule;
import com.axemble.vdoc.sdk.system.mail.beans.IMailTemplate;

import jakarta.mail.Session;
import jakarta.mail.Message;
import jakarta.ws.rs.core.MediaType;

import java.util.Properties;
import java.util.Date;

public class MyClass {
	
	private void myFunction(IBasePortalModule portalModule, IMailTemplate mailTemplate) {
		MimeMessage mimeMessage = new MimeMessage(Session.getInstance(new Properties()));
		mimeMessage.setRecipient(Message.RecipientType.TO, "myRecipientMailAddress@visiativ.com");
		mimeMessage.setContent(mailTemplate.getFullMail(), MediaType.TEXT_HTML + "; charset=UTF-8");
		mimeMessage.setFrom("mySenderAddress@visiativ.com");
		mimeMessage.setSubject(mailTemplate.getSubject(), "UTF-8");
		mimeMessage.setSentDate(new Date());
		portalModule.send(mimeMessage);
	}
}