It it possible to change the from address when using sendEmail?
If you use GMailApp.sendMail (instead of MailApp.sendEmail) you can specify a from as an optional additional parameter: https://developers.google.com/apps-script/reference/gmail/gmail-app#sendEmail(String,String,String,Object)
I believe you can only specify aliases that you have already configured your Gmail account with.
Google is not flexible on this one - the only "from" address that you can see is the one belonging to the user whose authority is running the script.
Instead of running as "the programmer", you can use a "robot" google account, something like [email protected]
. You can develop your scripts as yourself, then republish them from the robot.
Within a Google Apps Domain, your admin can create this psuedo-user and edit the settings to hide them from the Google Apps Directory, if that's desireable.
The email that the students receive won't be from their instructor, but it won't be from you, either.
Yes you can and it's quite easy. Use the log to determine which spot in the array your alias is if you have multiple aliases. Then to test that you have the right array location use that in the log.
var aliases = GmailApp.getAliases()
Logger.log(aliases); //returns the list of aliases you own
Logger.log(aliases[0]); //returns the alias located at position 0 of the aliases array
GmailApp.sendEmail('[email protected]','From an alias', 'A message from an alias!', {'from': aliases[0]});