Take pains to (do something)

To work carefully and conscientiously at something.

I took pains to write a very important email.