cancel
Showing results for 
Search instead for 
Did you mean: 

sending an email via website

idiotsguide
Champ in-the-making
Champ in-the-making
Hi everyone,

I have built a website around my alfresco system (4.0), using the quickstart as my base, but I'm working on a contact us form and having a problem. I have created a simple form in my contactus.get.html.ftl file, and i've created a contactus.post.js file. In here I want to email myself to notify me that someone has filled out the form. I've been looking around all the documentation, etc and came across this….

var mail = actions.create("mail");
mail.parameters.to = "me@me.com";
mail.parameters.subject = "Someone has used the contact us form";
mail.parameters.from = "website@thewebsite.com";
mail.parameters.text = "All good";
mail.execute();

Which I have been trying to get working but this is what I get when the script runs..
Failed to execute script 'org.springframework.extensions.webscripts.ResourceStore$WebApplicationStoreScriptContent@2080bcd8': 04200010 ReferenceError: "actions" is not defined.

Am I completely on the wrong track here? (Just when I thought I was getting my head around Alfresco!).
I'd be most grateful if anyone could help.

Thanks.
17 REPLIES 17

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
That looks fine to me…. Let me give it a try

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
just tested it and it works for me…

idiotsguide
Champ in-the-making
Champ in-the-making
Thanks for looking  amandaluniz_z,
I'm still getting the same error. I don't suppose I need to expose the "actions" to my webscript in any way do I?
It's a standard installation that's been done, so I'm pulling my hair out now! I just can't see what i'm missing.

Thanks again.

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
No you don't… the 'actions' object is available there…

Is that everything you have in your javascript file?

mrogers
Star Contributor
Star Contributor
Are you running your code on a server side webscript or are you in a WQS context.  If WQS then you won't have any repository services like the action service available.

idiotsguide
Champ in-the-making
Champ in-the-making
Hi Guys,
Sorry, my knowledge of alfresco is quite limited, I'm very much still learning.
Yes, that is pretty much all I have in my webscript, but to be honest I'm not sure if it runs server side or client side. I assumed server side.
Like I said, i'm just changing the standard quickstart website, so I'm modifying the contactus.get.html.ftl, etc that are already in the webscripts/ folders.

Thanks for your help so far.

idiotsguide
Champ in-the-making
Champ in-the-making
Hi mrogers,
Just re-read your reply.
I do have access to things like remote.connect, etc as I've been using them, so I have (maybe mistakenly) assume that is was server side.
I do have this code in the post.js rather than the get.js, would that make a difference?

Thanks again

idiotsguide
Champ in-the-making
Champ in-the-making
I don't suppose anyone else could help?
I'm now wondering if I'm totally barking up the wrong tree, but it does seem like a simple thing to want to do. I just want to send an email out from the wcmq website on a form submit. Does anyone else have any suggestions on how to do that?

Thanks

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
You're creating the webscript in a wcmqs site… You don't have the email send capability there…

What you could do is write a webscript in alfresco that sends the email using the "actions" root object and the passed parameters from the wcmqs site and send the email from Alfresco.

Adei