cancel
Showing results for 
Search instead for 
Did you mean: 

Attach a document into an email

mvicidomini
Champ in-the-making
Champ in-the-making
Hello all,

i would like to attach a document when it is uploaded to alfresco. I know that there is the default notification from the workflow but for internal reason my customers ask me to attach the original document into an email. I have writen a small script but i don't manage to attach the document does somebody has a solution thanks a lot.

var mail = actions.create("mail");
var docName = document.properties["name"];
var siteShortName = document.siteShortName;
//var mySite = getSite(shortName);
var prop = document.properties["nodeRef"]
mail.parameters.to = "MY EMAIL";
mail.parameters.subject = "Ajout de document";
mail.parameters.from = "MY EMAIL";
mail.parameters.text = "Ajout du document " + docName + "Sur le site: "+siteShortName+" Projet : "+space.name ;
mail.execute(document);
64 REPLIES 64

ruchin78
Champ in-the-making
Champ in-the-making
Hi Everyone,
I need to attach multiple documents in an workflow using javascript.
I have no idea about that as I am very new to it.
I appreciate, if anyone can help me in this regard.

Or, if I get any way to attach document to an existing workflow dynamically.

Regards
Ruchin Sharma

muristan
Champ in-the-making
Champ in-the-making
Hi Bob,

please send me your solution for mail with attachment to
Email - ak@muristan.de

Thanks
Andreas

frankakkerboom
Champ in-the-making
Champ in-the-making
Hi Bob,

Can you please send me a copy of the code you used, as I have a client who is requesting a similar thing. Please email to frankakkerboom@gmail.com

Thanks,

Frank

pnature
Star Contributor
Star Contributor

Hi,

I have tried your approach but I face problem with

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'fg-mail' is defined

I think that fg-mail (mail) is derivate that you mentioned.

Is it that one from Savic Prvoslav which you forward?

Could you please send it to me edo_nick@azet.sk

Thanks in advance

rjohnson
Star Contributor
Star Contributor

I have uploaded the file. It should be discoverable looking for documents titled Send HTML Mail With Attachments

The file is SendHTMLMailWithAttachments.zip. Source code is in the zip.

If you can't find it, reply & I will send it you directly.

pnature
Star Contributor
Star Contributor

Thank you. I found it.

pnature
Star Contributor
Star Contributor

Hi. I have tried to use this javascript in workflow script task.

Workflow failed with exception Smiley Sad

javax.script.ScriptException: ReferenceError: "actions" is not defined in <eval> at line number 1

This line contains: var mail = actions.create("fg-mail");

rjohnson
Star Contributor
Star Contributor

Eduard

Javascript in Workflows execute in a different context to Javascript in Alfresco and it seems Alfresco “actions” are not defined in that context. Alfresco workflow is Activiti which has some common objects, but not that many it would seem.

I have very little experience of workflow but this does not surprise me and I doubt that you could easily make Alfresco “actions” available in workflow.

To use my action you could use the following workaround:-

· Create a rule on the folder that contains the documents that will be in your workflows. It can be a set of folders & sub folders of course.

· Create a custom aspect called anything you like but let’s call it “sendmail” with properties mailsent (Boolean) and mailsentat (date).

· Get your workflow to add this aspect to your document when you want to send your email.

· Get you rule to check if this aspect exists on your document whenever your document is updated and if the aspect doesn’t exists add it, send the mail and update the properties. If the aspect does exist, check the values and see if mailsent is true. If it isn’t, send the mail and update the properties.

Now; I suspect that you could make my special mail object available in Activiti via configuration, but that is well beyond my paygrade.

Bob

iphost_zan
Confirmed Champ
Confirmed Champ

Hi rjohnson,

I installed alfresco 5.1 and I have the same problem Smiley Sad 
could you please send me your code? My mail is: paul.zan@gmail.com

Thank you so much

Paul

Paul

The source is available within the portal.

Search for

SendHTMLMailWithAttachments.zip

If you can’t find it; let me know.

Bob