How to send dam asset rendition as an attachment in email
Hi ,
I am trying to send a DAM Asset rendition as an attachment via mail.
I am sending mails using org.apache.commons.mail.HtmlEmail package.
If i use the below code
EmailAttachment attachment = new EmailAttachment();
attachment.setURL(new URL("http://localhost:4502/content/dam/geometrixx/new.jpg");
attachment.setDisposition(EmailAttachment.ATTACHMENT);
attachment.setDescription(assetName);
attachment.setName(assetName);
email.attach(attachment);
i am getting the error org.apache.sling.auth.core.impl.SlingAuthenticator getAnonymousResolver: Anonymous access not allowed by configuration - requesting credentials
If i use
File assetRendition = asset.adaptTo(File.class);
DataSource datasource = new FileDataSource(assetRendition);
email.attach(datasource,"Image Name","Image Desc");
I am getting null pointer exception.
If anyone has already used , please let me know how to resolve this.
Thanks in advance
Harish