Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-27
9
Medium Priority
?
293 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

 
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

How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

Question has a verified solution.

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

The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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 …

670 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