Lothian and Borders Police said a 51-year-old officer has been suspended as part of inquiries into "inappropriate and offensive" material.
The emails were detected at the force's G Division, based in Hawick in the Borders.
All the officers involved were constables and sergeants, and the investigation surrounds men and women.
The force has a facility to monitor sent and received emails, as well as those exchanged internally within the organisation. The emails in question were discovered as a result of this scrutiny.
Deputy Chief Constable Bill Skelly said: "It is of huge disappointment to me, the force and, I am sure, the communities we serve, that emails of a racist and sexist nature were circulated on our system.
"I consider this to be a very serious matter and have instructed that a 51-year-old police officer is suspended and that further inquiries should be carried out.
"Initial work has identified another 20 individuals - 16 officers and four police staff - who appear to be involved in this issue.
"They have been spoken to and advised that they are subject to misconduct inquiries. While these inquiries are ongoing it would be inappropriate to comment further."
He added: "The vast majority of Lothian and Borders Police employees are dedicated to their communities and act at all times with the utmost respect.
"Unfortunately there are occasions when a very small minority fall well below the standards we expect.
"I would like to reassure the public that when this happens we consider their behaviour unacceptable and deal with the issue with the seriousness it deserves.
"All staff of Lothian and Borders Police receive extensive training and there are clear guidelines in place on email and internet use.
"The force is now in consultation with partners and representatives of community groups regarding what additional measures may be appropriate."
There are 249 officers and 47 civilian staff based at G Division.