How to automatically respond to an e-mail - google-apps-script

I would like to automatically respond to an e-mail with some information. The idea is to provide a self-service way for students to get grades and passwords. I see sample scripts that work on e-mails, but I need to:
look for a keyword in the subject to understand what type of information to provide (i.e., grade, password, etc.)
look at the e-mail of the inbound e-mail to identify the student (optionally locate a password)
look up the information (possibly in a spreadsheet)
create an e-mail and send it to the student
I am more familiar with using scripts with e-mail and spreadsheets, but I would prefer to create this on a Google Sites page or embed it in a wiki.
Thanks in advance for the help,
JDF

I am not sure how much detail you were looking for, or if you where looking for example code, but here are some high level things to think about.
First, if you are going to embed the code into a webpage that you want be able to access all your other Google things easaly. eg if i stored all the student names passwords and student numbers in an spreadsheet or database you have to set up permission to do so. Your website does not count as you "persay" because if you had it shared out then someone could potentally steal all your google stuff.
Take a good look through the Google appi google apps script. You can search your email by thread (subeject) and then go through the emails like that. I think all the function that you want are there.

Related

Get username without requiring it

There's an interesting problem I'm facing as an educator. I want to collect user names in a form, but when I do that, it automatically enables students to email themselves a copy of their response.
I believe there's a way to somehow poll who's responded. When you enable the "one response per user" option, it doesn't require a stored user name. I know the information is out there somewhere - I just don't know how to get to it.
Any help would be greatly appreciated!
EDIT: I neglected to be specific about the coding aspect - apologies. I'm generating the form programmatically, and wanted to know if the information is stored somewhere in the response when the one-response-per-person option is enabled. After more digging, it appears that the easiest way to deal with this is to use an extension to handle disabling the email option.
Thanks for all your help!
you cant get the user email unless you enable that option like you mentioned. yes google might internally know who you are if you were already logged-in but its not perfect because using chrome incognito mode for example would not detect the email.
one way I can think is to:
1) with apps script generate an array of all student emails and a random password. dump to a private spreadsheet and use as your database for the next script.
2) in your forms, ask first as a form question the custom username and password.
3) on another script you can generate form urls with prefilled usernames and passwords and email each student their own custom form url.
when the student opens the form to respond, the username and password would be prefilled already.
not perfect but a malicious user would need to hack the email and if they can hack their email then they could also impersonate the user logged-in.

Auto-fill gmail BCC line based on To field

I am trying to augment my CRM that I have. The high level problem is that I've to enter multiple email addresses every time I want to write a message. This becomes a particular problem when replying to a message and forgetting to enter a special BCCed email address. I'd like to not have to remember to do that. I want, when I am using gmail, for an address in the To/CC line to trigger an auto-population of an address in the BCC line.
Here is how I think I would do this now:
My idea is to do, implement a map/dict/whatever by using two columns in a google spreadsheet (sheet) document. (Using the sheet means an easy visualization to my dict and an easy ability to share with permissions etc.)
The first column would be the To/CC email address and the second column would be the auto-populated BCC email address.
Then I'd like to have code run on my computer that allows me to use gmail as you would without having to think about whatever will automatically go into the BCC field. (Bonus points for figuring out a way for me to code something up that allows me to not have to think about this when sending email from the gmail app on my iPhone.)
It may seem from my abstract description that I would need to hire someone to do this but I know I can code this myself. I just need to be pointed to the correct APIs and be notified of any gotchas that I should avoid.
Currently I was going to write a google contextual gadget to handle auto populating the field. Is that the best way? Or is a greasemonkey/whatever script better? What is the general approach I should take to tackling the problem?
To fix the phone/other-email-frontend problem would a Google Apps Script that acts like a cron job to check the most recent sent emails and if they don't have the proper bcc then just forward those emails with an appropriate bcc be reasonable?
Basically, am I off base or on track with my solution? If I am on track give me a bit more information on appropriate plan of attack. If I am off base then point me in the right direction.
I would appreciate your help.
I don't think you are going to be able to do this inside of gmail. You could save a bunch of Drafts with the correct BCC emails, and put the TO: email in the subject line so that you could see who that draft was meant for, then change the subject line.
You could have a dialog box in your spreadsheet that you designed to look like an email compose screen. That would be the most straight forward approach. You could have a stand alone App, that had an input screen that was designed to look like an email compose screen.
Basically, you'd need to design your own user interface rather than using gmail. But the gmail compose window isn't anything very complicated, so if it's just a plain text email, it should be easy enough.
Your question would be more understandable with a concrete example of the problem (I'm not sure I entirely understand it). But Gmail supports mailto: URLs quite well. Perhaps that is the answer to what you want to do.
There are various scripts to help you generate a mailto: the way you want, so have a look at something like http://sislands.com/coin70/week6/mailtoCreator.htm

How to give write permissions only to UI app to write data to a Spreadsheet

I have developed a web application using Google scripts UIApp class which will collect the data of work done by each associate and writes data to my spreadsheet.
Problem I'm facing is I have to share my spreadsheet to all the associates with write permission where it enables them to see others data. I want to hide this sheet from all but they should also be able write data using the web application I shared.
Please let me know for more details or any code snippets
Note: I have Not used Google Form because I need change the list values dynamically based on the selection and the type of user.
You can deploy the app you have built with UiApp to be executed as "you" and allow access to anyone. The spreadsheet won't need to be shared anymore but as it is anyone (even anonymous if you are not in a domain) will be able to use it...
You'll have to implement an access control yourself, again this will be different in a domain or in a "normal" gmail account (in a domain you can get the user email, in a gmail account you can't)
(since apparently I can't comment.. but to follow up on this question.)
Is there a best practice for running as something other than really-yourself?
Say a team is managing it, or your a contractor who won't stay with the company, and so you're account and access is likely to go away.
I assume it results in creating a shared account, or perhaps a groups or something? You start getting into all sorts of ACL issues. And a simple ``run as yourself'' doesn't seem like a good long term solution.

Solution for Gmail Email Blast

Why: I'm a parent-teacher organization chairperson responsible for email communication to a community of 750 to 1,000. We switched to Gmail recently to save money.
What I do: I split my distribution list into groups of less than 250 people each. I write one email and then copy/paste the contents into multiple others. I place my distribution groups into each email BCC line and click send on each of the multiple emails.
What I'd like to do: Write one email and send without exceeding the per-email limit. Perhaps a google script can help? I've been looking at mail merge scripts, but they seem to be built for one at a email send at a time. Any ideas are appreciated.
Use google groups. Will solve all your issues plus you will write a single email.
I think you can do it with a gmail admin account. If not buy a google spps domain for a single user and do it from there.

geteditors not returning emails the ui decides is a group

So you create a document in drive, then share it. You share it to someone inside google's network, the email address gets an icon of a single dude. But if you share it with someone outside of googles network, you get an icon of multiple dudes. At least you do when you share it with security set to anyone with the link can get in. Im not sure if this works in the other modes.
but anyways, you now write an app script that wants to send an email to everyone the file is shared with. so you use DocsList to get the file, then call the getEditors method to get the list of people that the file is shared with. The problem is it looks like that method only returns the email addresses with the icon of the single dude. How do I get the other email addresses?
If that can't happen, how do I tell Drive that the external email address I'm adding is in fact a person and not a group?
I think that happened because you shared to someone that do not have a google account.
In order to see the document with an identified ID they must have a google account (that do not mean a google email adress) You can create an account associated to your email adress here
for the second part of the question you can refer to that previous question here