A goodbye email is sent to co-workers usually on the last working day in an organization. It is a means of expressing gratitude for the learning opportunities you got there.
Like any formal email, a goodbye mail should be kept short and to the point. Do not digress unnecessarily. Highlight the positive parts of your work and you can also highlight the projects where you have enjoyed working together, keeping the tone casual here. Humor can also be used, depending on the office atmosphere.
A personal touch may be added by mentioning certain co-workers who have guided you in your stint in the organization. Thank everyone graciously for their support and wish them luck on their future endeavor. You can end the email by adding your contact details so that your colleagues can be in touch with you.