Hi everyone,
After upgrading from Mendix 9 to Mendix 10, I encountered issues with the deprecated Email Template module. Instead of rebuilding the entire email logic using the Email Connector microflows, I implemented a Java-based workaround that retains existing templates and resolves compatibility issues.
✅ What I Did:
userlib
:
jakarta.activation-2.0.1.jar
jakarta.activation-api-1.2.1.jar
javax.mail-1.6.0.jar
javax.mail-1.6.2.jar
EmailMessage
from the Email Connector moduleThe changed code snippet is shown below:
package emailtemplate.mail;
import com.mendix.core.Core;import com.mendix.core.CoreException;import com.mendix.systemwideinterfaces.core.IContext;import com.mendix.systemwideinterfaces.core.IMendixObject;import email_connector.proxies.EmailMessage;import java.util.List;import java.util.Map;
public class Sender { private final IContext context;
public Sender(IContext _context) { this.context = _context; }
public void send(SMTPConfiguration configuration, Message message, String subject, List<String> toAddressList, List<String> ccAddressList, List<String> bccAddressList, List<IMendixObject> attachments, Map<String, String> headers) throws CoreException { // Create EmailMessage Mendix object EmailMessage emailMsg = new EmailMessage(context); emailMsg.setSubject(subject); if (toAddressList != null && !toAddressList.isEmpty()) { emailMsg.setTo(String.join(",", toAddressList)); } if (ccAddressList != null && !ccAddressList.isEmpty()) { emailMsg.setCC(String.join(",", ccAddressList)); } if (bccAddressList != null && !bccAddressList.isEmpty()) { emailMsg.setBCC(String.join(",", bccAddressList)); } if (message.getPlainBody() != null) { emailMsg.setPlainBody(message.getPlainBody()); } if (message.getHtmlBody() != null) { emailMsg.setContent(message.getHtmlBody()); } // Attachments: associate IMendixObject attachments to EmailMessage if needed // This may require setting associations via Core.addAssociation or similar // Headers: if needed, set as custom attributes or ignore if not supported // Send email using Mendix Email Connector microflow // Example: Core.execute(context, "Email_Connector.SendEmail", params); // You may need to build a parameter map with the EmailMessage Mendix object }}
Has anyone else tried a similar approach? Would love to hear your feedback or improvements.
Wow Vishva, your article was really helpful for our Mendix upgrade! Good work..