[xwiki-users] Can I send email to a group with xwiki 6?
Hello, I want send mail from xwiki to inform XWikiAllGroup of my xwiki upgrade I tested with Invitation application and share by email without success. Both want email or xwiki username. Is it possible? Thxs. Pascal BASTIEN
I don't think there's any UI for this, but it could be scripted. I would use the new Mail Sender API ( http://extensions.xwiki.org/xwiki/bin/view/Extension/Mail+Sender+API ). Iterating the list of users from a group and getting their email address shouldn't be that hard. Hope this helps, Marius On Wed, Jul 16, 2014 at 12:22 PM, Pascal BASTIEN <[email protected]> wrote:
Hello,
I want send mail from xwiki to inform XWikiAllGroup of my xwiki upgrade
I tested with Invitation application and share by email without success. Both want email or xwiki username.
Is it possible?
Thxs.
Pascal BASTIEN _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Thxs. I will use a loop then. ________________________________ De : Marius Dumitru Florea <[email protected]> À : Pascal BASTIEN <[email protected]>; XWiki Users <[email protected]> Envoyé le : Lundi 21 juillet 2014 15h38 Objet : Re: [xwiki-users] Can I send email to a group with xwiki 6? I don't think there's any UI for this, but it could be scripted. I would use the new Mail Sender API ( http://extensions.xwiki.org/xwiki/bin/view/Extension/Mail+Sender+API ). Iterating the list of users from a group and getting their email address shouldn't be that hard. Hope this helps, Marius On Wed, Jul 16, 2014 at 12:22 PM, Pascal BASTIEN <[email protected]> wrote:
Hello,
I want send mail from xwiki to inform XWikiAllGroup of my xwiki upgrade
I tested with Invitation application and share by email without success. Both want email or xwiki username.
Is it possible?
Thxs.
Pascal BASTIEN _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Sorry I didn't take the time to writing this loop (another priorities on Xwiki) But I hope to find some time to writing it... :-) ________________________________ De : Shaddy <[email protected]> À : [email protected] Envoyé le : Mardi 26 août 2014 10h02 Objet : Re: [xwiki-users] Can I send email to a group with xwiki 6? Pascal BASTIEN <pbasnews-xwiki@...> writes:
Thxs. I will use a loop then.
________________________________
Hello everybody, I'm currently working on the same issue. Can you show how you managed to send an email to a group of users?? Thank you very much. Daniele. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Hello, (freely inspired/adapted by: http://extensions.xwiki.org/xwiki/bin/view/Extension/Test+Mail (Vincent) and http://xwiki.markmail.org/message/bksyjlpwezx4dgco?q=getAllMembersNamesForGr... (Sergiu) Some questions: to replace some text in velocity, I used $text.replaceAll(xxx,yyy). Are they a way to use StringUtils tools in velocity? http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/org/apache/co... If yes, how? I failed to get email adress with $userdoc.display("email","view",$user) function but without "mailto:" prefix ... http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/Docum... Are they a tip with wrappingSyntaxId value? or I must use regexp like i did? If there are too much email I don't know if my macro is safe... (Perhaps there are a way to insert a sleep instruction in velocity?) Thxs Anyway, here my script to send email at all xwiki users: Note: to test/debug, modify this lines: {{code}} #if ($ToEmail != '' && $ToEmail == '[email protected]') ##if ($ToEmail != '') {{/code}} ---- {{velocity}} #if($xwiki.hasAccessLevel('admin')) #if ("$!{xwiki.getXWikiPreference('admin_email')}" != '') #set ($RobotEmail="$!{xwiki.getXWikiPreference('admin_email')}") #else {{error}}You must fill admin email in Xwiki preference page{{/error}} #end ## All Team Members on the Wiki (using velocity) #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #if("$!{request.action}" == 'send_mail' && "$!{request.lastname}" == '') ## Check submission and honey pot. #if("$!request.subject" != '') ## loop on each email users #foreach ($user in $allUsers) #set ($userdoc = $xwiki.getDocument($user)) #set ($email = $userdoc.display("email","view",$user)) ##Clean email adress (remove mailto:) #set ($ToEmail = $email.replaceAll('^mailto:','')) ##SMTP adress to test/debug ##send to one user #if ($ToEmail != '' && $ToEmail == '[email protected]') ##if ($ToEmail != '') ##send mail ##set($result = $xwiki.mailsender.sendTextMessage("[email protected]", $request.recipient, $request.subject, "$!request.message")) #set($result = $xwiki.mailsender.sendTextMessage("$RobotEmail", "$ToEmail", $request.subject, "$!request.message")) #if($result == -1) {{error}}A problem occurred while sending the mail to $email.{{/error}} #else ## {{info}}Everything went OK.{{/info}} * mail sent to $email #end #end #end #else {{error}}Please specify at least a subject{{/error}} #end #end {{html wiki=true}} <form action="" method="post"> <input name="action" value="send_mail" type="hidden" /> ## this is a honey-pot hidden text field hat hopefully robots will not leave empty <div class="hidden"> <input name="lastname" type="text" /> </div> <fieldset> **FROM** (admin email): $RobotEmail<br /> **SUBJECT:**<br /> <input type="text" name="subject" /><br /> **MESSAGE:**<br /> <textarea name="message" style="width:99%;" rows=10>Your test message here.</textarea> </fieldset> <div> <span class="buttonwrapper"><input type="submit" class="button" value="Send" /></span> </div> </form> {{/html}} #else {{error}}Oops. Area restricted to Admins, sorry.{{/error}} #end ---- Liste des destinataires du mail ci-dessus (tous les membres de Iwiki): = Recipient list: All Team Members on the Wiki (using velocity) = #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers) #set ($userdoc = $xwiki.getDocument($user)) #set ($email = $userdoc.display("email","view",$user)) #set ($TexteMail = $email.replaceAll('^mailto:','')) ##set ($TexteMail = $escapetool.xml($userdoc.display("email","view",$user))) ##set ($TexteMail = StringUtils.removeStart("$userdoc.display("email","rendered",$user)", "mailto")) #if ($email != 'mailto:') $user -> $email ##$user -> $email $TexteMail #end #end {{/velocity}} **************************** **************************** If you want to send email to a group, here the code to list email users by groups (copy/paste the interesting piece): {{velocity}} Utilisateurs connectés actuellement: $xwiki.rightsmanager.usersApi.allUsersNames ------ Liste tous mes groupes #set($rightsAPI=$xwiki.rightsmanager) #set($groupsAPI=$rightsAPI.getGroupsApi()) #set($groups=$groupsAPI.getAllLocalGroupsNames()) #foreach($group in $groups) * [[$group]] #end ------- Get the email of all users in a group (using velocity) ## This request ##set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiGroups'") ##set ($allGroups = $xwiki.searchDocuments($sql)) ## OR thisAPI #set($rightsAPI=$xwiki.rightsmanager) #set($groupsAPI=$rightsAPI.getGroupsApi()) #set($allGroups=$groupsAPI.getAllLocalGroupsNames()) #foreach ($group in $allGroups) * $group #set ($groupdoc = $xwiki.getDocument($group)) ##set ($groupMembers = $util.sort($xwiki.rightsmanager.getAllMembersNamesForGroup($groupdoc.name))) #set ($groupMembers = $util.sort($xwiki.rightsmanager.getAllMembersNamesForGroup($group))) ## groupedoc.name $groupdoc.name ##set ($groupMembers = $xwiki.rightsmanager.getAllMembersNamesForGroup("$groupdoc.name")) #set ($groupMembers = $xwiki.rightsmanager.getAllMembersNamesForGroup($group)) ##$groupMembers #foreach ($mem in $groupMembers) #set ($userdoc = $xwiki.getDocument($mem)) ##set ($em = $userdoc.display("email","view",$mem)) $em<br> #set ($em = $userdoc.display("email","view",$mem)) #if ($em != 'mailto:') $em #end #end #end ------------- All Team Members on the Wiki (using velocity) #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers) #set ($userdoc = $xwiki.getDocument($user)) #set ($mail = $userdoc.display("email","view",$user)) #if ($mail != 'mailto:') $user $mail #end #end {{/velocity}} Pascal B ________________________________ De : Pascal BASTIEN <[email protected]> À : XWiki Users <[email protected]> Envoyé le : Mardi 26 août 2014 10h23 Objet : Re: [xwiki-users] Can I send email to a group with xwiki 6? Sorry I didn't take the time to writing this loop (another priorities on Xwiki) But I hope to find some time to writing it... :-) ________________________________ De : Shaddy <[email protected]> À : [email protected] Envoyé le : Mardi 26 août 2014 10h02 Objet : Re: [xwiki-users] Can I send email to a group with xwiki 6? Pascal BASTIEN <pbasnews-xwiki@...> writes:
Thxs. I will use a loop then.
________________________________
Hello everybody, I'm currently working on the same issue. Can you show how you managed to send an email to a group of users?? Thank you very much. Daniele. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Just my 2 cents: If you plan to send a lot of emails though the Internet, then your emails may be rejected by the mail providers, considering they are spams. If you send emails internally, it should not be a problem. 2014-09-24 16:15 GMT+02:00 Pascal BASTIEN <[email protected]>:
Hello,
(freely inspired/adapted by: http://extensions.xwiki.org/xwiki/bin/view/Extension/Test+Mail (Vincent) and http://xwiki.markmail.org/message/bksyjlpwezx4dgco?q=getAllMembersNamesForGr... (Sergiu)
Some questions: to replace some text in velocity, I used $text.replaceAll(xxx,yyy). Are they a way to use StringUtils tools in velocity?
http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/org/apache/co... If yes, how? I failed to get email adress with $userdoc.display("email","view",$user) function but without "mailto:" prefix ...
http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/Docum... Are they a tip with wrappingSyntaxId value? or I must use regexp like i did?
If there are too much email I don't know if my macro is safe... (Perhaps there are a way to insert a sleep instruction in velocity?)
Thxs
Anyway, here my script to send email at all xwiki users:
Note: to test/debug, modify this lines: {{code}} #if ($ToEmail != '' && $ToEmail == '[email protected]') ##if ($ToEmail != '') {{/code}}
----
{{velocity}}
#if($xwiki.hasAccessLevel('admin')) #if ("$!{xwiki.getXWikiPreference('admin_email')}" != '') #set ($RobotEmail="$!{xwiki.getXWikiPreference('admin_email')}") #else {{error}}You must fill admin email in Xwiki preference page{{/error}} #end
## All Team Members on the Wiki (using velocity) #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql))
#if("$!{request.action}" == 'send_mail' && "$!{request.lastname}" == '') ## Check submission and honey pot. #if("$!request.subject" != '')
## loop on each email users #foreach ($user in $allUsers) #set ($userdoc = $xwiki.getDocument($user)) #set ($email = $userdoc.display("email","view",$user)) ##Clean email adress (remove mailto:) #set ($ToEmail = $email.replaceAll('^mailto:',''))
##SMTP adress to test/debug ##send to one user #if ($ToEmail != '' && $ToEmail == '[email protected]') ##if ($ToEmail != '')
##send mail ##set($result = $xwiki.mailsender.sendTextMessage(" [email protected]", $request.recipient, $request.subject, "$!request.message")) #set($result = $xwiki.mailsender.sendTextMessage("$RobotEmail", "$ToEmail", $request.subject, "$!request.message")) #if($result == -1) {{error}}A problem occurred while sending the mail to $email.{{/error}} #else ## {{info}}Everything went OK.{{/info}} * mail sent to $email #end #end #end
#else {{error}}Please specify at least a subject{{/error}} #end #end
{{html wiki=true}} <form action="" method="post"> <input name="action" value="send_mail" type="hidden" /> ## this is a honey-pot hidden text field hat hopefully robots will not leave empty <div class="hidden"> <input name="lastname" type="text" /> </div> <fieldset> **FROM** (admin email): $RobotEmail<br /> **SUBJECT:**<br /> <input type="text" name="subject" /><br /> **MESSAGE:**<br /> <textarea name="message" style="width:99%;" rows=10>Your test message here.</textarea> </fieldset> <div> <span class="buttonwrapper"><input type="submit" class="button" value="Send" /></span> </div> </form> {{/html}} #else {{error}}Oops. Area restricted to Admins, sorry.{{/error}} #end
----
Liste des destinataires du mail ci-dessus (tous les membres de Iwiki): = Recipient list: All Team Members on the Wiki (using velocity) =
#set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers) #set ($userdoc = $xwiki.getDocument($user)) #set ($email = $userdoc.display("email","view",$user)) #set ($TexteMail = $email.replaceAll('^mailto:','')) ##set ($TexteMail = $escapetool.xml($userdoc.display("email","view",$user))) ##set ($TexteMail = StringUtils.removeStart("$userdoc.display("email","rendered",$user)", "mailto")) #if ($email != 'mailto:') $user -> $email ##$user -> $email $TexteMail #end #end
{{/velocity}}
**************************** ****************************
If you want to send email to a group, here the code to list email users by groups (copy/paste the interesting piece):
{{velocity}} Utilisateurs connectés actuellement: $xwiki.rightsmanager.usersApi.allUsersNames
------ Liste tous mes groupes #set($rightsAPI=$xwiki.rightsmanager) #set($groupsAPI=$rightsAPI.getGroupsApi()) #set($groups=$groupsAPI.getAllLocalGroupsNames()) #foreach($group in $groups) * [[$group]] #end
------- Get the email of all users in a group (using velocity) ## This request ##set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiGroups'") ##set ($allGroups = $xwiki.searchDocuments($sql)) ## OR thisAPI #set($rightsAPI=$xwiki.rightsmanager) #set($groupsAPI=$rightsAPI.getGroupsApi()) #set($allGroups=$groupsAPI.getAllLocalGroupsNames())
#foreach ($group in $allGroups) * $group #set ($groupdoc = $xwiki.getDocument($group)) ##set ($groupMembers = $util.sort($xwiki.rightsmanager.getAllMembersNamesForGroup($groupdoc.name ))) #set ($groupMembers = $util.sort($xwiki.rightsmanager.getAllMembersNamesForGroup($group))) ## groupedoc.name $groupdoc.name ##set ($groupMembers = $xwiki.rightsmanager.getAllMembersNamesForGroup("$ groupdoc.name")) #set ($groupMembers = $xwiki.rightsmanager.getAllMembersNamesForGroup($group)) ##$groupMembers #foreach ($mem in $groupMembers) #set ($userdoc = $xwiki.getDocument($mem)) ##set ($em = $userdoc.display("email","view",$mem)) $em<br> #set ($em = $userdoc.display("email","view",$mem)) #if ($em != 'mailto:') $em #end #end #end -------------
All Team Members on the Wiki (using velocity)
#set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers) #set ($userdoc = $xwiki.getDocument($user)) #set ($mail = $userdoc.display("email","view",$user)) #if ($mail != 'mailto:') $user $mail #end #end
{{/velocity}}
Pascal B
________________________________ De : Pascal BASTIEN <[email protected]> À : XWiki Users <[email protected]> Envoyé le : Mardi 26 août 2014 10h23 Objet : Re: [xwiki-users] Can I send email to a group with xwiki 6?
Sorry I didn't take the time to writing this loop (another priorities on Xwiki) But I hope to find some time to writing it... :-)
________________________________ De : Shaddy <[email protected]> À : [email protected] Envoyé le : Mardi 26 août 2014 10h02 Objet : Re: [xwiki-users] Can I send email to a group with xwiki 6?
Pascal BASTIEN <pbasnews-xwiki@...> writes:
Thxs. I will use a loop then.
________________________________
Hello everybody,
I'm currently working on the same issue.
Can you show how you managed to send an email to a group of users??
Thank you very much.
Daniele.
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Guillaume Delhumeau ([email protected]) Research & Development Engineer at XWiki SAS Committer on the XWiki.org project
You are right. A random sleeping in velocity, inserted in my loop will be great to avoid this. Or concatenate all email to send only one mail with Bc. ... ? (It is not a problem for myself because I send emails internally. :-) ) ________________________________ De : "Guillaume "Louis-Marie" Delhumeau" <[email protected]> À : XWiki Users <[email protected]> Envoyé le : Mercredi 24 septembre 2014 17h25 Objet : Re: [xwiki-users] Can I send email to a group with xwiki 6? Just my 2 cents: If you plan to send a lot of emails though the Internet, then your emails may be rejected by the mail providers, considering they are spams. If you send emails internally, it should not be a problem. 2014-09-24 16:15 GMT+02:00 Pascal BASTIEN <[email protected]>:
Hello,
(freely inspired/adapted by: http://extensions.xwiki.org/xwiki/bin/view/Extension/Test+Mail (Vincent) and http://xwiki.markmail.org/message/bksyjlpwezx4dgco?q=getAllMembersNamesForGr... (Sergiu)
Some questions: to replace some text in velocity, I used $text.replaceAll(xxx,yyy). Are they a way to use StringUtils tools in velocity?
http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/org/apache/co... If yes, how? I failed to get email adress with $userdoc.display("email","view",$user) function but without "mailto:" prefix ...
http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/Docum... Are they a tip with wrappingSyntaxId value? or I must use regexp like i did?
If there are too much email I don't know if my macro is safe... (Perhaps there are a way to insert a sleep instruction in velocity?)
Thxs
Anyway, here my script to send email at all xwiki users:
Note: to test/debug, modify this lines: {{code}} #if ($ToEmail != '' && $ToEmail == '[email protected]') ##if ($ToEmail != '') {{/code}}
----
{{velocity}}
#if($xwiki.hasAccessLevel('admin')) #if ("$!{xwiki.getXWikiPreference('admin_email')}" != '') #set ($RobotEmail="$!{xwiki.getXWikiPreference('admin_email')}") #else {{error}}You must fill admin email in Xwiki preference page{{/error}} #end
## All Team Members on the Wiki (using velocity) #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql))
#if("$!{request.action}" == 'send_mail' && "$!{request.lastname}" == '') ## Check submission and honey pot. #if("$!request.subject" != '')
## loop on each email users #foreach ($user in $allUsers) #set ($userdoc = $xwiki.getDocument($user)) #set ($email = $userdoc.display("email","view",$user)) ##Clean email adress (remove mailto:) #set ($ToEmail = $email.replaceAll('^mailto:',''))
##SMTP adress to test/debug ##send to one user #if ($ToEmail != '' && $ToEmail == '[email protected]') ##if ($ToEmail != '')
##send mail ##set($result = $xwiki.mailsender.sendTextMessage(" [email protected]", $request.recipient, $request.subject, "$!request.message")) #set($result = $xwiki.mailsender.sendTextMessage("$RobotEmail", "$ToEmail", $request.subject, "$!request.message")) #if($result == -1) {{error}}A problem occurred while sending the mail to $email.{{/error}} #else ## {{info}}Everything went OK.{{/info}} * mail sent to $email #end #end #end
#else {{error}}Please specify at least a subject{{/error}} #end #end
{{html wiki=true}} <form action="" method="post"> <input name="action" value="send_mail" type="hidden" /> ## this is a honey-pot hidden text field hat hopefully robots will not leave empty <div class="hidden"> <input name="lastname" type="text" /> </div> <fieldset> **FROM** (admin email): $RobotEmail<br /> **SUBJECT:**<br /> <input type="text" name="subject" /><br /> **MESSAGE:**<br /> <textarea name="message" style="width:99%;" rows=10>Your test message here.</textarea> </fieldset> <div> <span class="buttonwrapper"><input type="submit" class="button" value="Send" /></span> </div> </form> {{/html}} #else {{error}}Oops. Area restricted to Admins, sorry.{{/error}} #end
----
Liste des destinataires du mail ci-dessus (tous les membres de Iwiki): = Recipient list: All Team Members on the Wiki (using velocity) =
#set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers) #set ($userdoc = $xwiki.getDocument($user)) #set ($email = $userdoc.display("email","view",$user)) #set ($TexteMail = $email.replaceAll('^mailto:','')) ##set ($TexteMail = $escapetool.xml($userdoc.display("email","view",$user))) ##set ($TexteMail = StringUtils.removeStart("$userdoc.display("email","rendered",$user)", "mailto")) #if ($email != 'mailto:') $user -> $email ##$user -> $email $TexteMail #end #end
{{/velocity}}
**************************** ****************************
If you want to send email to a group, here the code to list email users by groups (copy/paste the interesting piece):
{{velocity}} Utilisateurs connectés actuellement: $xwiki.rightsmanager.usersApi.allUsersNames
------ Liste tous mes groupes #set($rightsAPI=$xwiki.rightsmanager) #set($groupsAPI=$rightsAPI.getGroupsApi()) #set($groups=$groupsAPI.getAllLocalGroupsNames()) #foreach($group in $groups) * [[$group]] #end
------- Get the email of all users in a group (using velocity) ## This request ##set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiGroups'") ##set ($allGroups = $xwiki.searchDocuments($sql)) ## OR thisAPI #set($rightsAPI=$xwiki.rightsmanager) #set($groupsAPI=$rightsAPI.getGroupsApi()) #set($allGroups=$groupsAPI.getAllLocalGroupsNames())
#foreach ($group in $allGroups) * $group #set ($groupdoc = $xwiki.getDocument($group)) ##set ($groupMembers = $util.sort($xwiki.rightsmanager.getAllMembersNamesForGroup($groupdoc.name ))) #set ($groupMembers = $util.sort($xwiki.rightsmanager.getAllMembersNamesForGroup($group))) ## groupedoc.name $groupdoc.name ##set ($groupMembers = $xwiki.rightsmanager.getAllMembersNamesForGroup("$ groupdoc.name")) #set ($groupMembers = $xwiki.rightsmanager.getAllMembersNamesForGroup($group)) ##$groupMembers #foreach ($mem in $groupMembers) #set ($userdoc = $xwiki.getDocument($mem)) ##set ($em = $userdoc.display("email","view",$mem)) $em<br> #set ($em = $userdoc.display("email","view",$mem)) #if ($em != 'mailto:') $em #end #end #end -------------
All Team Members on the Wiki (using velocity)
#set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers) #set ($userdoc = $xwiki.getDocument($user)) #set ($mail = $userdoc.display("email","view",$user)) #if ($mail != 'mailto:') $user $mail #end #end
{{/velocity}}
Pascal B
________________________________ De : Pascal BASTIEN <[email protected]> À : XWiki Users <[email protected]> Envoyé le : Mardi 26 août 2014 10h23 Objet : Re: [xwiki-users] Can I send email to a group with xwiki 6?
Sorry I didn't take the time to writing this loop (another priorities on Xwiki) But I hope to find some time to writing it... :-)
________________________________ De : Shaddy <[email protected]> À : [email protected] Envoyé le : Mardi 26 août 2014 10h02 Objet : Re: [xwiki-users] Can I send email to a group with xwiki 6?
Pascal BASTIEN <pbasnews-xwiki@...> writes:
Thxs. I will use a loop then.
________________________________
Hello everybody,
I'm currently working on the same issue.
Can you show how you managed to send an email to a group of users??
Thank you very much.
Daniele.
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Guillaume Delhumeau ([email protected]) Research & Development Engineer at XWiki SAS Committer on the XWiki.org project _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
On 09/24/2014 10:15 AM, Pascal BASTIEN wrote:
Hello,
(freely inspired/adapted by: http://extensions.xwiki.org/xwiki/bin/view/Extension/Test+Mail (Vincent) and http://xwiki.markmail.org/message/bksyjlpwezx4dgco?q=getAllMembersNamesForGr... (Sergiu)
Some questions: to replace some text in velocity, I used $text.replaceAll(xxx,yyy). Are they a way to use StringUtils tools in velocity? http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/org/apache/co... If yes, how?
Yes, $stringtool
I failed to get email adress with $userdoc.display("email","view",$user) function but without "mailto:" prefix ... http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/Docum...
Use $user.getProperty('email').value to access the raw value, display methods generate HTML code.
Are they a tip with wrappingSyntaxId value? or I must use regexp like i did?
If there are too much email I don't know if my macro is safe... (Perhaps there are a way to insert a sleep instruction in velocity?)
Thxs
-- Sergiu Dumitriu http://purl.org/net/sergiu
2014-09-24 22:27 GMT+02:00 Sergiu Dumitriu <[email protected]>:
On 09/24/2014 10:15 AM, Pascal BASTIEN wrote:
Hello,
(freely inspired/adapted by: http://extensions.xwiki.org/xwiki/bin/view/Extension/Test+Mail (Vincent) and http://xwiki.markmail.org/message/bksyjlpwezx4dgco?q=getAllMembersNamesForGr... (Sergiu)
Some questions: to replace some text in velocity, I used $text.replaceAll(xxx,yyy). Are they a way to use StringUtils tools in velocity?
http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/org/apache/co...
If yes, how?
Yes, $stringtool
I failed to get email adress with $userdoc.display("email","view",$user) function but without "mailto:" prefix ...
http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/Docum...
Use $user.getProperty('email').value to access the raw value, display methods generate HTML code.
Since 6.2, you can do $user.getValue('email') :)
Are they a tip with wrappingSyntaxId value? or I must use regexp like i did?
If there are too much email I don't know if my macro is safe... (Perhaps there are a way to insert a sleep instruction in velocity?)
Thxs
-- Sergiu Dumitriu http://purl.org/net/sergiu _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Guillaume Delhumeau ([email protected]) Research & Development Engineer at XWiki SAS Committer on the XWiki.org project
"it's a kind of magic" for $stringtool :-) ... but I didn't manage to use $user.getProperty('email').value or $user.getValue('email') I try this: {{velocity}} #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers) ##cut ... #if ($email != 'mailto:') ## $user -> $email $user -> $user.getProperty('email').value - $user.getValue('email') #end #end {{/velocity}} and this: {{velocity}} #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers) #set ($MyUser = $xwiki.getUser("$user")) #if ($email != 'mailto:') ## $user -> $email $user -> $MyUser.getProperty('email').value - $MyUser.getValue('email') #end #end {{/velocity}} without success :-( ________________________________ De : "Guillaume "Louis-Marie" Delhumeau" <[email protected]> À : XWiki Users <[email protected]> Envoyé le : Jeudi 25 septembre 2014 9h19 Objet : Re: [xwiki-users] Can I send email to a group with xwiki 6? 2014-09-24 22:27 GMT+02:00 Sergiu Dumitriu <[email protected]>:
On 09/24/2014 10:15 AM, Pascal BASTIEN wrote:
Hello,
(freely inspired/adapted by: http://extensions.xwiki.org/xwiki/bin/view/Extension/Test+Mail (Vincent) and http://xwiki.markmail.org/message/bksyjlpwezx4dgco?q=getAllMembersNamesForGr... (Sergiu)
Some questions: to replace some text in velocity, I used $text.replaceAll(xxx,yyy). Are they a way to use StringUtils tools in velocity?
http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/org/apache/co...
If yes, how?
Yes, $stringtool
I failed to get email adress with $userdoc.display("email","view",$user) function but without "mailto:" prefix ...
http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/Docum...
Use $user.getProperty('email').value to access the raw value, display methods generate HTML code.
Since 6.2, you can do $user.getValue('email') :)
Are they a tip with wrappingSyntaxId value? or I must use regexp like i did?
If there are too much email I don't know if my macro is safe... (Perhaps there are a way to insert a sleep instruction in velocity?)
Thxs
-- Sergiu Dumitriu http://purl.org/net/sergiu _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Guillaume Delhumeau ([email protected]) Research & Development Engineer at XWiki SAS Committer on the XWiki.org project _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
On Thu, Sep 25, 2014 at 11:18 AM, Pascal BASTIEN <[email protected]> wrote:
"it's a kind of magic" for $stringtool :-)
... but I didn't manage to use $user.getProperty('email').value or $user.getValue('email')
I try this: {{velocity}}
#set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers) ##cut ...
#if ($email != 'mailto:') ## $user -> $email
$user -> $user.getProperty('email').value - $user.getValue('email')
You can always do $someVariable.class.name to see the Java class name and then to look for the corresponding javadoc to see the available method. In this case, $user is a plain Java string so it doesn't have the 'getProperty' method. If you don't believe me, look for 'searchDocuments' in http://platform.xwiki.org/xwiki/bin/view/SRD/Navigation?api=xwiki&xpage=embe... You need a Document object. See http://platform.xwiki.org/xwiki/bin/view/SRD/Navigation?api=doc&xpage=embed which has 'getValue'. #set ($userDoc = $xwiki.getDocument($user)) $user.getValue('email')
#end #end
{{/velocity}}
and this:
{{velocity}} #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers)
#set ($MyUser = $xwiki.getUser("$user"))
getUser return an object of type User, http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/User.... , which doesn't have any getProperty or getValue method but has getEmail. You really need to check the type of objects you are using.
#if ($email != 'mailto:') ## $user -> $email $user -> $MyUser.getProperty('email').value - $MyUser.getValue('email') #end #end
{{/velocity}}
without success :-(
________________________________ De : "Guillaume "Louis-Marie" Delhumeau" <[email protected]> À : XWiki Users <[email protected]> Envoyé le : Jeudi 25 septembre 2014 9h19 Objet : Re: [xwiki-users] Can I send email to a group with xwiki 6?
2014-09-24 22:27 GMT+02:00 Sergiu Dumitriu <[email protected]>:
On 09/24/2014 10:15 AM, Pascal BASTIEN wrote:
Hello,
(freely inspired/adapted by: http://extensions.xwiki.org/xwiki/bin/view/Extension/Test+Mail (Vincent) and http://xwiki.markmail.org/message/bksyjlpwezx4dgco?q=getAllMembersNamesForGr... (Sergiu)
Some questions: to replace some text in velocity, I used $text.replaceAll(xxx,yyy). Are they a way to use StringUtils tools in velocity?
http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/org/apache/co...
If yes, how?
Yes, $stringtool
I failed to get email adress with $userdoc.display("email","view",$user) function but without "mailto:" prefix ...
http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/Docum...
Use $user.getProperty('email').value to access the raw value, display methods generate HTML code.
Since 6.2, you can do $user.getValue('email') :)
Are they a tip with wrappingSyntaxId value? or I must use regexp like i did?
If there are too much email I don't know if my macro is safe... (Perhaps there are a way to insert a sleep instruction in velocity?)
Thxs
-- Sergiu Dumitriu http://purl.org/net/sergiu _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Guillaume Delhumeau ([email protected]) Research & Development Engineer at XWiki SAS Committer on the XWiki.org project
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
... next time, before asking too quickly I will take more time to read/understand the doc :-/ Note: for accounts without email: $userDoc.getValue('email') return XWiki.xwikiblog -> $userDoc.getValue('email') $MyUser.getEmail() return XWiki.xwikiblog -> I will probably publish a simplest formulaire which propose a list of groups... when I have more time. Here correct code (to adapt with previous code for groups): {{velocity}} #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers) #set ($userDoc = $xwiki.getDocument($user)) #if ($email != 'mailto:') ## $user -> $email $user -> $userDoc.getValue('email') #end #end ---- #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers) #set ($MyUser = $xwiki.getUser("$user")) #if ($email != 'mailto:') ## $user -> $email $user -> $MyUser.getEmail() #end #end {{/velocity}} Thxs everybodys ________________________________ De : Marius Dumitru Florea <[email protected]> À : Pascal BASTIEN <[email protected]>; XWiki Users <[email protected]> Envoyé le : Jeudi 25 septembre 2014 10h56 Objet : Re: [xwiki-users] Can I send email to a group with xwiki 6? On Thu, Sep 25, 2014 at 11:18 AM, Pascal BASTIEN <[email protected]> wrote:
"it's a kind of magic" for $stringtool :-)
... but I didn't manage to use $user.getProperty('email').value or $user.getValue('email')
I try this: {{velocity}}
#set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers) ##cut ...
#if ($email != 'mailto:') ## $user -> $email
$user -> $user.getProperty('email').value - $user.getValue('email')
You can always do $someVariable.class.name to see the Java class name and then to look for the corresponding javadoc to see the available method. In this case, $user is a plain Java string so it doesn't have the 'getProperty' method. If you don't believe me, look for 'searchDocuments' in http://platform.xwiki.org/xwiki/bin/view/SRD/Navigation?api=xwiki&xpage=embe... You need a Document object. See http://platform.xwiki.org/xwiki/bin/view/SRD/Navigation?api=doc&xpage=embed which has 'getValue'. #set ($userDoc = $xwiki.getDocument($user)) $user.getValue('email')
#end #end
{{/velocity}}
and this:
{{velocity}} #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers)
#set ($MyUser = $xwiki.getUser("$user"))
getUser return an object of type User, http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/User.... , which doesn't have any getProperty or getValue method but has getEmail. You really need to check the type of objects you are using.
#if ($email != 'mailto:') ## $user -> $email $user -> $MyUser.getProperty('email').value - $MyUser.getValue('email') #end #end
{{/velocity}}
without success :-(
________________________________ De : "Guillaume "Louis-Marie" Delhumeau" <[email protected]> À : XWiki Users <[email protected]> Envoyé le : Jeudi 25 septembre 2014 9h19 Objet : Re: [xwiki-users] Can I send email to a group with xwiki 6?
2014-09-24 22:27 GMT+02:00 Sergiu Dumitriu <[email protected]>:
On 09/24/2014 10:15 AM, Pascal BASTIEN wrote:
Hello,
(freely inspired/adapted by: http://extensions.xwiki.org/xwiki/bin/view/Extension/Test+Mail (Vincent) and http://xwiki.markmail.org/message/bksyjlpwezx4dgco?q=getAllMembersNamesForGr... (Sergiu)
Some questions: to replace some text in velocity, I used $text.replaceAll(xxx,yyy). Are they a way to use StringUtils tools in velocity?
http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/org/apache/co...
If yes, how?
Yes, $stringtool
I failed to get email adress with $userdoc.display("email","view",$user) function but without "mailto:" prefix ...
http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/Docum...
Use $user.getProperty('email').value to access the raw value, display methods generate HTML code.
Since 6.2, you can do $user.getValue('email') :)
Are they a tip with wrappingSyntaxId value? or I must use regexp like i did?
If there are too much email I don't know if my macro is safe... (Perhaps there are a way to insert a sleep instruction in velocity?)
Thxs
-- Sergiu Dumitriu http://purl.org/net/sergiu _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Guillaume Delhumeau ([email protected]) Research & Development Engineer at XWiki SAS Committer on the XWiki.org project
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (5)
-
Guillaume "Louis-Marie" Delhumeau -
Marius Dumitru Florea -
Pascal BASTIEN -
Sergiu Dumitriu -
Shaddy