It is grammatically correct to say "By way of this email, ..." and it would be understood correctly, however it would be seen as a very strange way to phrase this. It is not idiomatic.
Your suggestion of "The purpose of this email is to inform you ..." is an improvement, idiomatically, but you are also correct that phrasing it this way would be seen as harsh. The register of this expression is very, very formal. Formality of this level is usually reserved for legal proceedings, which are typically hostile in nature-- possibly extremely hostile.
The correct idiomatic phrase would be "This email is to inform you..." which is still formal, but not quite as formal as "The purpose of this email is to inform you ...". It would be appropriate for normal business communications with an agent of another company that you have not established a closer relation with.
If you have a very good relationship with the particular agent you are communicating with, perhaps you've been working with them for months on a project and even eaten lunch with them, a more casual approach would be more appropriate. In this case, you would write something like "Hey {their name}, just wanted to let you know that our contract has ended with you guys." and then either continue with "Did you want to renew?" or "I'm sorry to see you go, it's been great working with you" depending on how your companies are proceeding.