In principle, a formal notice is not mandatory before taking legal action.
However, it is very useful and strongly recommended since it may allow you to settle your dispute without having to go to court. We often settle a case simply by sending a letter explaining to the party at fault what their obligations are and what they are exposed to if they do not respect them. This way, you can get what you want at a lower cost.
Furthermore, if you sue someone without having first sent a formal notice and that person agrees with you within a reasonable time following the sending of your proceedings, you will not be able to claim the legal fees to which you would normally be entitled.
The formal notice also has the effect of starting interest on your monetary claim.
However, there are situations where a demand letter would be useless and it is better not to invest in sending a letter. Take the example of a person who has clearly stated his intention not to pay you even if he receives a demand letter.