Q:

Why is javascript not executed inside email?

I sent a mail with some javascript to somemail@gmail.com, the html part is working and I am able to see the button. But when i click on the button and try to invoke a function inside I am not able to do so.

How is gmail able to block my js script ?
It is nice to see gmail blocking the javascript inside any gmail clients, ok they are now with great security, but how does this happen ? In my original mail(attached below) there is no stripping of the js script by server, It is just passed to client (chrome in my case) and the client does not execute. Does the client maintain a list where it has to execute the js and where it must not. WHO IS THE ONE STOPPING CHROME EXECUTING THE js script. Now if I create my own mail server, in that case who/what will stop my client from executing the js inside ???
Why does it do it ?

My original mail is here

A:

How is gmail able to block my js script ?

Because HTML email contains HTML, HTML is text, text can be edited programatically, and the emails are sent to servers that Google controls.

In my original mail(attached below) there is no stripping of the js script by serve

That includes all the email headers. It looks like you have asked GMail to give you the raw source of the email. It does so, but encodes all the HTML so that it renders as text.
If you want to see the HTML delivered to the browser when the HTML is being rendered as HTML, you will need to use the DOM Inspector feature of your browser('s developer tools). 

Why does it do it ?

Browsers perform a lot of sandboxing on JavaScript and put very strict limits on what it is allowed to do. Many of those limits are based around the Origin of the page in which the JavaScript runs. Emails sent to Gmail are turned into webpages and sent to the browser from gmail.com (or another Google domain). If any JavaScript was left in the page, then it would run from that origin — the browser would consider the script to be trusted by GMail — which would be a terrible security hole.
A simple example of an exploit would be for the JavaScript to grab the innerHTML of the page (which includes lots of account information), generate a <form> with DOM, and then submit all that data to the attacker's server.
A more complicated attack would use XHR to go through the entire email account and copy the details of every message there.
Or it might send emails using the account.
Or many other things.

