Handling user reference "#user" from script app - google-apps-script

I am struggling with the following:
A have a spreadsheet with user references created by putting the "#" sign in front of the name - so when I drag the cursor above I get e-mail address etc. - but while reading this using script I can only read is as name and surname of the user - but cannot refer to her/his e-mail address.
It there a possibility to read a #user reference to get straight to the e-mail address?
Regards,
Jedrzej
In most cases the user e-mail address can be created from the name and surname - therefore I have created a function that handle it - but sometimes I get issues as there are several individuals who have e-mail address not related with their name.

Related

Classroom.profiles.get returns 'User does not have permission'

I am trying to write a simple function to get all the students names and email addresses for a given class. The students have a mixture of mydomain.ac.uk and gmail.com. The students that have a mydomain.ac.uk address all return without problem, but if the student has a gmail account, I get the error 'The caller does not have permission'.
If I view the People tab of the course using the same superAdmin account that runs the code, I can see all of the students names and can email them. How do I get my code to return the userProfile of these gmail account users?
var sEmail = Classroom.UserProfiles.get({'userId' : '111294713083730379429'}).emailAddress
If I can see this information in the Classroom, why can't I access the same information in my code?
From the question
If I can see this information in the Classroom, why can't I access the same information in my code?
Only Google can answer why. Please bear in mind that the user profile data for #gmail.com is stored on an external domain, gmail.com.
I suggest you to checkout the Google Classroom Issue Tracker if there is already an issue about this "feature".

EWS Managed API 2, setting sender/from display name

I'm trying to set the display name of the sender on an e-mail. I have tried to set both the Sender and From attributes of the EmailMessage but neither seem to change the display name - the e-mail always arrives with the actual name associated with the Exchange account.
Is there a way to successfully change the name that is displayed without changing the name of the account or changing to another account?
No when the message arrives in the Target Mailbox the Information store will resolve the Address back to the Native (EX) Address of the recipient which will mean if you look at the address in the Client it will always appear as the primary. This is the way Exchange has always worked and can't be controlled.

Existence of an email id in a domain

How to check a Google app account is present in a domain or not using Google app script (with email id)?
I would like to reset the password of accounts in my domain. Before that i need to check if those accounts exists in my domain or not. So with a given email id, i need to check id this particular email id is present in my domain or not and it should be primary email address.
Please let me know if this is feasible or not.
Thanks
I think you can try to retrieve all users in your domain by following this documentation.
To retrieve all users in the same domain, use the following GET request and include the authorization described in Authorize requests. For readability, this example uses line returns:
GET https://www.googleapis.com/admin/directory/v1/users ?domain=primary domain name&pageToken=token for next results page
&maxResults=max number of results per page
&orderBy=email, givenName, or familyName
&sortOrder=ascending or descending
&query=email, givenName, or familyName:the query's value*
Also check this SO question, if it can help you.

adding email domain name verification to a website

I want to add email verification for the sign up page for my webpage. I want more then just regular expression verifying to check if the email is in the correct format.
What is the correct method / how do i go by implementing some sort of check to see if domain names are valid domain names?
I have a function that connects to the mail server and checks the email ttps://github.com/hbattat/verifyEmail

Generate unique link for each website visitor

I send 3 different links to people on a daily basis. I know the name of the person I am sending the link to. How do I attach that persons information to the link to know they clicked on the link?
I sent close to 50 emails to different people. I just want to be notified that someone I sent the link to click on it.
You need to use a database for this. The link could contain a random hash that can be looked up in the "emails" table. This table could keep records for timestamps, specifically when the emial was sent out, and when the user clicked the link.
#QUESTION:
Most hosting providers give you the option to hook up a database. If you have trouble finding this, use google or their support. As far as how to "use" a database, you will need to learn this in you own time. But like anything else the basics are widely available through google, which in your case, is all you need to finish your project.
You can add an encrypted or obfuscated field to your URLs identifying the email address.
Common methods:
base64 encoded email address XOR-ed with known key
md5 hash of email address truncated to first N characters
And so on.
The first method allows you to reverse the process (i.e. getting back the email address from the visit log), the second is one-way only.
For example, using the second method with email dude#gmail.com (truncated to 12 characters):
http://domain.com/click.php?v=ec3ab9422d7a
Or, as already said, you can simply use a database and store a key-value pair (email, hash) with, for each email, a random string generated on-the-fly by your massmailer.