As your question is not terribly specific I can only guess at what you mean. If by user activity you mean keyboard or mouse, then this can by implemented in a few different ways. In a bash script you can use the command xprintidle (in the standard repositories). Then, if you have the appropriate email set up, you can use e.g. the mail command to send the email.
Alternatively, after detecting the timeout you can also call e.g. a python script and get it to send and email using standard protocols and you favorite email account e.g. gmail. You can read about that e.g. here For sompleteness sake, I have pasted the code example from that page here:
fromaddr = 'email@example.com'
toaddrs = 'firstname.lastname@example.org'
msg = 'There was a terrible error that occured and I wanted you to know!'
# Credentials (if needed)
username = 'username'
password = 'password'
# The actual mail send
server = smtplib.SMTP('smtp.gmail.com:587')
server.sendmail(fromaddr, toaddrs, msg)
If you want, you can also keep the entire thing in python. The standard recipe is to use the ctypes module to access libX. I have previously tried implementing one of these recipes and (with the exception of sometime having to replace a few of the lib paths) it works really well. I wont paste those code examples here as they are huge and found on several websites e.g. here, if you want more search for "python x idle time" maybe add ubuntu or linux.
If you have more specific questions to one of these approaches let me know and please also elaborate a little more in your question.