Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-09-27
9
Medium Priority
?
296 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Accepted Solution

by:
cnpz earned 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

916 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