There's no way to email legislators directly. The only way is to fill out their forms. Each form is unique, and many have CAPTCHAs.
To do that, we first had to develop an open source dataset that describes to a computer the steps necessary to submit messages via each contact form for 538 representatives. That was quite a lift, but was made possible by about 100 volunteers who chipped in. The dataset is called contact-congress, and is online here: https://github.com/unitedstates/contact-congress
Then we had to create a system to fill in the forms based on the dataset. The system we designed is called phantom-of-the-capitol and it does that by firing up 3 browser windows on an AWS instance each time a user submits a message. If the legislator has a CAPTCHA, we take a screenshot and return that to the user. The code for that system is here: https://github.com/EFForg/phantom-of-the-capitol