Here is a simple function for use with Elastic Email for uploading files. The file can then be used for mail merges or sent as an attachment. If you look at my previous post you will see:

LOCAL.httpService.addParam(type="formfield",name="data_source",value=ARGUMENTS.myBean.getMergeName());

This is the name of the file that is uploaded by the upload function. So with this you send an email using a template which the variables are populated dynamically from a bean to csv file full of recipients.

 

    public string function elasticEmailUpload(upLoadName,fileName)
        {
            LOCAL.httpService = new http();
            LOCAL.httpService.setMethod("put");
            LOCAL.httpService.setCharset("utf-8");
            LOCAL.uploadURL=THIS.UPLOADURL & ARGUMENTS.upLoadName;
            LOCAL.httpService.setUrl(LOCAL.uploadURL);
            LOCAL.httpService.addParam(type="file",name="#ARGUMENTS.upLoadName#",file="#ARGUMENTS.fileName#",mimetype="Content-type: text/csv");
            LOCAL.httpService.addParam(type="formfield",name="username",value=THIS.USERNAME);
            LOCAL.httpService.addParam(type="formfield",name="api_key",value=THIS.API_KEY);
            LOCAL.httpService.addParam(type="formfield",name="filename",value=ARGUMENTS.upLoadName);
            LOCAL.result = LOCAL.httpService.send().getPrefix();
            return LOCAL.result.Statuscode;
        }