Solved

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

Posted on 2011-09-27
9
284 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to ToolkitScriptManager 2 31
Error viewing ASP page 12 97
Path to Python 9 46
Recommendation vb6 to vb.net or others 14 41
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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.
The viewer will learn how to dynamically set the form action using jQuery.
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 …

759 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

22 Experts available now in Live!

Get 1:1 Help Now