Here is a better function I think. It uses the builtin org-contacts database:
(defun insert-emails-from-tags (tag-expression) "insert emails from org-contacts that match the tags expression. For example: group-phd will match entries tagged with group but not with phd." (interactive "sTags: ")
(insert (mapconcat 'identity (loop for contact in (org-contacts-filter) for contact-name = (car contact) for email = (org-contacts-strip-link (car (org-contacts-split-property
(or (cdr (assoc-string org-contacts-email-property (caddr contact))) ""))))
for tags = (cdr (assoc "TAGS" (nth 2 contact))) for tags-list = (if tags (split-string (substring (cdr (assoc "TAGS" (nth 2 contact))) 1 -1) ":")
'()) if (let ((todo-only nil)) (eval (cdr (org-make-tags-matcher tag-expression))))
----------------------------------- John Kitchin Associate Professor Doherty Hall A207F Department of Chemical Engineering
Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 http://kitchingroup.cheme.cmu.edu