send email with xml attatchment

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
sharifu
Active Member

send email with xml attatchment

I am using alfresco 4.2.c. I want to create a rule which triggers a script that will send an email with xml file that contains all properties of that document that was updated. so far I have come across posts which are old and related to version 3.x of alfesco. I need some clarification for version 4.x

<javascript>
function sendMail()
{
    var mail = actions.create("mail");
    mail.parameters.to = "sharif.uddin@domain.com"; //bpm_groupAssignees.properties["cm:email"];
    mail.parameters.subject = "New File uplodaded with name " + document.name;
    mail.parameters.from = "alfresco@domain.com";//initiator.properties["cm:email"];
    mail.parameters.text = "Kindly approve the document: " + document.name;
   mail.parameters.node=document;
    mail.execute(document);
}

function createXML(){   
   var v = new  XMLWriter();
   v.writeStartDocument(true);
   v.writeElementString('test','Hello World');
   v.writeAttributeString('foo','bar');
   v.writeEndDocument();
   //console.log( v.flush() );
}

//createXML();
sendMail();
</javascript>

mail.parameters.node=document; does not work.
3 Replies
rjohnson
Established Member

Re: send email with xml attatchment

The standard mail action does not allow attachments. You need to create a derivative. There is one on the internet which I downloaded and it works fine with 4.2c but I really can't remember where I got it from.

Happy to share it with your but I can't attach it to this post so send me a message with an email address & I will forward it on.

Alternatively, Google for "alfresco mail with attachments action" and you should find it.

That said, this allows you to attach an Alfresco document, so you would have to create the XML document in Javascript, save it to the reporsitory and then you could attach it. Thats easy enough to do with a couple of extra lines of code in your example above.
sharifu
Active Member

Re: send email with xml attatchment

I have come across http://savicprvoslav.blogspot.co.uk/2010/10/send-html-email-from-alfresco-33-with.html which i managed to get working however on line 364 `message.addAttachment("test.pdf", file);` i want to replace test.pdf with the filename of the node being attatched. how would i do this?
rjohnson
Established Member

Re: send email with xml attatchment

I used the same code as the basis for my add-on but it looks like I edited it. I cannot post it here its to big. Message me and I will email it you.


Please note this build was run against Alfresco 4.0d; I have never used anything less than 4.0a.