views:

67

answers:

2

I have a content type meeting that has a CCK node referer field that refers to one or more people nodes. Those people nodes contain a CCK Email field.

Now I'd like to send a mail to all people listed in the meeting node when the node is created. I don't know how to do that as the mail adresses are in different nodes, so I can't just send a tokenized mail, as those adresses are not available as tokens (as far as I can see).

Any idea on how to do that, preferably without writing a custom module.

Edit:

There seems to be no quick and easy way do to this, so I'll probably have to write some custom code to do that. I'm already using the Rules module, what would be the preferred way to programatically create a mail action? Do I have to create the mail stuff from scratch or can I modify some existing code?

A: 

I'm not sure I understand. From reading your question, I would answer "Rules" can do that for you. But then in your edit you say that you use the rules module and you want to create a mail action?

I may be just tired, but please elaborate, and we'll see if we can work it out :)

Claes
Rules could do it if the mail address is in the same node, but it is in a different node that is referenced by nodereferrer. So I can't just use "Send tokenized mail", as the mail address is not one of the provided tokens. I was thinking of creating a custom action that could then read the mail addresses directly from the database.
Fabian
+1  A: 

It looks like you may be able to use a combination of the Rules, Views, and Rules and Views Integration modules to accomplish your goal.

  1. Create a view that returns the email address of People associated with a Meeting.
  2. Configure the view to "render" its results into a rule that sends emails to the resulting addresses.
  3. Create a rule that executes the view created in step 1 when a Meeting is created.

Please note that I haven't tried Rules and Views Integration myself, so it may not work as I expect. Additionally, I am uncertain if there is an email action for Rules that will take the output of your view as a parameter.

Greg
Thanks, this method works. The combination of Rules and Views is absurdly powerful, if somewhat complicated. You can create ruleset that take parameters (which are available as tokes in rules) and render a view to a ruleset mapping fields to parameters.
Fabian
@Fabian - Awesome, I'll have to try it out for myself soon!
Greg