I've got working email sender, but without attachments. I tried something like this:
Simple input in HTML:
<input type="file" simple-change="uploadFiles($event)"/>
JS file picker:
$scope.uploadFiles = function (event) {
$scope.file= event.target.files[0];
};
And JS email sender:
$scope.sendEmail = function(){
$scope.emailData = new EmailData();
$scope.emailData.to = "[email protected]";
$scope.emailData.from = "[email protected]";
$scope.emailData.subject = "Errors";
$scope.emailData.title = $scope.topic;
$scope.emailData.description = $scope.description;
$scope.emailData.template = "templateErrors";
$http.post("sendemail/attachment", $scope.emailData, $scope.file, {headers: {'Content-Type': undefined} })
.then(function (response) {
$scope.succes = true;
},
function(fail) {
$scope.error = true;
});
}
Java Controller:
@RequestMapping(value = "/attachment", method = RequestMethod.POST)
public EmailStatus sendEmailAttach(@RequestBody EmailData emailData, CommonsMultipartFile file) {
return emailSenderAttachment.sendDataAttach(emailData, file);
}
but still got error 500: ""message":"org/apache/commons/fileupload/FileUploadException""
Please help :(