Solved

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

Posted on 2011-09-27
9
285 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
 
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now