Sending mails with images using MailAttachmentsManager

Hi, I’m developing a postfunction that creates and sends an e-mail and I want to include the avatar of the user. I found the interface MailAttachmentsManager, but I haven’t found any examples of how to create the object. I’ve tried this:

JiraHome jiraHome = new DefaultJiraHome();
AvatarTagger avatarTagger = new AvatarTaggerImpl(jiraHome);
AvatarTranscoder avatarTranscoder = new AvatarTranscoder(ComponentAccessor.getAvatarManager(), avatarTagger);
MailAttachmentsManager mailAttachmentsManager = new MailAttachmentsManagerImpl(ComponentAccessor.
getAvatarService(), avatarTranscoder, ComponentAccessor.getUserManager(), ComponentAccessor.getAvatarManager(), ComponentAccessor.getApplicationProperties());

But, I get the error: java.lang.InstantiationError: com.atlassian.jira.avatar.AvatarTranscoder
can anybody help me?

Have you tried the following?

MailAttachmentsManager mailAttachmentsManager = ComponentAccesor.getComponent(MailAttachmentsManager.class)

This should retrieve an Instance if it is available via dependency injection.

Thank you. No, I haven´t tried this, it will probably work. To create the AvatarTranscoder object was my problem. I finally managed to solve in this way:

MailAttachmentsManagerFactory mailAttManagerFactory = new MailAttachmentsManagerFactory(ComponentAccessor.getAvatarManager(), 
				ComponentAccessor.getAvatarService(), ComponentAccessor.getComponent(AvatarTranscoder.class), ComponentAccessor.getUserManager(), ComponentAccessor.getApplicationProperties());