1
0
-1

following code below what properties map to add attachment to email by using plugin.


import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.joget.apps.app.model.AppDefinition;
import org.joget.apps.app.service.AppPluginUtil;
import org.joget.apps.app.service.AppUtil;
import org.joget.plugin.base.ApplicationPlugin;
import org.joget.plugin.base.Plugin;
import org.joget.plugin.base.PluginManager;
import org.joget.plugin.property.model.PropertyEditable;
  
public Object execute(AppDefinition appDef, HttpServletRequest request) {
    String[] emails = new String[]{"email@example.com"};
     
    //Reuse Email Tool to send separated email to a list of users;
    Plugin plugin = pluginManager.getPlugin("org.joget.apps.app.lib.EmailTool");
     
    //Get default properties (SMTP setting) for email tool
    Map propertiesMap = AppPluginUtil.getDefaultProperties(plugin, null, appDef, null);
    propertiesMap.put("pluginManager", pluginManager);
    propertiesMap.put("appDef", appDef);
    propertiesMap.put("request", request);
     
    ApplicationPlugin emailTool = (ApplicationPlugin) plugin;
     
    //send email
    for (String email : emails) {
        propertiesMap.put("toSpecific", email);
        propertiesMap.put("subject", "This is a test email for " + email);
        propertiesMap.put("message", "Email content for " + email+ "");
        propertiesMap.put("Attachments","https://www.orimi.com/pdf-test.pdf");
        
        
        //set properties and execute the tool
        ((PropertyEditable) emailTool).setProperties(propertiesMap);
        emailTool.execute(propertiesMap);
    }
     
    return null;
}
  
//call execute method with injected variable
return execute(appDef, request);

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1
        CommentAdd your comment...