Hello,
Thank you for your answer, but I'm sorry, I don't understand what you mean
by CM.
Thanks,
Stéphanie
2012/5/29 Vincent Massol <vincent(a)massol.net>
> FYI I've just done this in a training I gave last week and it worked
> nicely.
>
> Can you show us the code you've used to register the event listener
> against the CM?
>
> Thanks
> -Vincent
>
> On May 29, 2012, at 9:12 AM, Stéphanie wrote:
>
>> Hello everyone,
>>
>> I'm trying to send an automatic email and this is the idea I have had.
>>
>> I used the "Groovy Notification Tutorial"
>> (
>
http://platform.xwiki.org/xwiki/bin/view/DevGuide/GroovyNotificationTutorial
> )
>> and instead of writing in a file, I try to send an email.
>>
>> This is my code (I only copy the method onEvent, I didn't change the
> rest) :
>>
>> void onEvent(Event event, Object source, Object data)
>> {
>> // Prevent infinite recursion since in this example we log to wiki
>> page which
>> // triggers a document change... :)
>> if (source.fullName != "Main.Logger") {
>> def sender = context.user.substring(6)
>> def emailcc = xwiki.null
>> def emailbcc = xwiki.null
>> def pageattachments = []
>> def emailcontent = "Test"
>> def result =
> xwiki.mailsender.sendHtmlMessage("${sender}",
>> "name(a)gmail.com".com", emailcc, emailbcc, "Test du mail",
emailcontent,
>> document.getContent(), pageattachments)
>> def document = xwiki.getDocument("Main.Logger")
>> document.setContent("Sender : ${sender} / Content :
>> ${emailcontent}")
>> document.save("Logging event", true)
>> }
>> }
>>
>> But when I try this, nothing happened. I don't have any error message so
> I
>> don't know if I make something wrong.
>>
>> Do you have an idea of how doing this ?
>>
>> Thank you very much for your future answer,
>> Stéphanie