In a view, everytime a user clicks on a link "click to connect" field, an email has to be sent to the specific username based on its id. I am using webform to send the mail. But, it restricts me to send all mails to the same email address. In order to hide the email to which mail has to be sent, I am fetching the id of the user(to whom mail has to be sent) in a hidden field in webform. But, i cant figure out a way to get the destination email dynamically.
2 Answers
Why not activate individual user contact forms, add a User: Link to contact page field to your view, and put your 'Click to connect' in the Text to display?
This will allow users to control whether or not they wish to receive such emails. They will be able to opt out in their account page and the link will not appear in the view.
This won't directly answer your question but
http://drupal.org/project/mimemail will format your mail all pretty like with html goodness.
http://drupal.org/node/37480 v6 & http://drupal.org/project/mailsystem v7 will handle all the heavy lifting.
There's quite a few tutorials on boath google is really your friend there with out more information on how you want to send them. Rules can, triggers can, Cron can, and modules can with hooks. They all can be sent "at a button press" so to speak. Rules though is probably where you want to look if your going for plug and pray sort of approach. A custom module will involve the api & hooks.
Good reading at http://drupal.org/node/1124376 v6/7/8 Please also specifiy which version of Drupal you are asking about since each version has different modules & api.