Solved

How to build a contact list but keep the email addresses hidden

Posted on 2011-09-27
9
287 Views
Last Modified: 2013-11-19
I would like to create a simple google site with a list of names, however I would like to keep the email addresses hidden from the users. I would like to create a basic list with names like Joe S and then an "email Joe S: link right next to his name. By clicking the link the user could email Joe S. My perfect scenario, would be to allow the user to multi select since some users may want to send a message to 2 of the 5 people in the list. The list will never be more than 40 people. I guess let's start with the basics, how can I accomplish the email task?
0
Comment
Question by:sqlagent007
  • 5
  • 4
9 Comments
 
LVL 4

Expert Comment

by:cnpz
ID: 36714112
Hi Mr Bond,

I'll try to get some time later to write a full how-to, but I think an easy approach would be:

1. Create a Google Spreadsheet
2. Create a form with checkboxes as per http://climbtothestars.org/archives/2009/09/06/google-forms-multiple-choice-list-checkbox/
3. Create an OnSubmit script to email the "ticked" people: http://code.google.com/googleapps/appsscript/articles/sending_emails.html
4. Embed the form in the site

You could also do everything using Apps Script UI, or create a custom gadget and embed that...

Like I said, hoping to get a bit of time in the next day or two, but hope the above helps.
0
 
LVL 1

Author Comment

by:sqlagent007
ID: 36894458
Thank you! I am going to try your solution this weekend. Then I will accept the solution.
0
 
LVL 1

Author Comment

by:sqlagent007
ID: 36914991
I created a spreadsheet with 2 rows, email in column A and message in column B. I am able to work through this example as long as the data stays only in columns A and B.


However, I am not able to figure out how to "relate" the check boxes in the form to the names in the spreadsheet. How to I take input from the form into my script? How do I tell the script to take the check boxes as input, then match on the text of the name, and execute?
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 4

Accepted Solution

by:
cnpz earned 500 total points
ID: 36915246
Hi SQLAgent,

This is kinda messy code, but if you create a sheet with the form, then add a sheet called 'Names' that has Name and Email columns (in that order), then you can create a script as per below, triggered on form submit. Assumes your list of names to email ends up in the B column. You can have Subject etc in the other cells, just reference them with getRange to set the subject, body. Make sure the trigger is using myFunction, too.


function myFunction() {
  var sheet = SpreadsheetApp.getActiveSheet();
  sheet.sort(1, false);
  var people = sheet.getRange('B2').getValue().split(', ');
  for (i in people)
  {
    var addr = findName(people[i]);
    MailApp.sendEmail(addr, 'Hi', addr);
  }
  
}


function findName(v) {
  var sh = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Names');
  var r = sh.getDataRange().getValues();
  for(i in  r)
  {
     if(r[i][0] == v)
       return r[i][1];
    
  }
  return '';
  
}

Open in new window

0
 
LVL 1

Author Comment

by:sqlagent007
ID: 36918363
This is awesome!!!! The only challenge I am having now is getting the [Enter eMail Message] data into the body of the email. I notived this line:
MailApp.sendEmail(addr, 'Hi', addr);
Is putting the email address in the body.

The only tricky part is that the email address is on the second sheet named [Names], however the message body is on the first sheet named [Sheet1]. I am getting the impression that sheet [names] is just like a lookup table in a database. How can I assign the [Sheet1].[ColumnC] to a varable and put that variable in the body of the email messsage?

I have attache screenshots.... This is the form, I have added txt to the jpgGoogle-Spreadsheet-w-2-tabs.jpg
0
 
LVL 4

Expert Comment

by:cnpz
ID: 36921069
After the line
sheet.sort(1, false);

insert

var bd = sheet.getRange('C2').getValue()

and then instead of

MailApp.sendEmail(addr, 'Hi', addr);

put

MailApp.sendEmail(addr, 'Hi', bd);


By the way, you could similarly repalce 'Hi' with a subject by adding it to your form - then just have a look at which columns represent which variable. For instance, if Subject is after Contents, it'll probably end up being D. And the line is always 2 because we're sorting the data by time (descending) before picking up the values. Hope that makes sense.

0
 
LVL 4

Expert Comment

by:cnpz
ID: 36921079
Oops - missed a ';' on the var bd = ... line.
0
 
LVL 1

Author Comment

by:sqlagent007
ID: 36921194
Your awesome! I am trying the code now. I already replaced the "Hi"...That one I figured out all by myself =)  
0
 
LVL 1

Author Closing Comment

by:sqlagent007
ID: 36921258
For those who want to implement this, be sure and read all of the posts.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question