A university in upstate New York is apologizing after it sent thousands of emails to potential students in error — telling them they were accepted to the school.

More than 5,000 letters from the State University of New York at Buffalo were sent by email, according to published reports.

In a statement the university said the “miscommunication occurred when an incorrect email list was generated from an applicant database.”

RELATED: Is your social media presence more important than your SAT score?

A letter of apology was emailed to those applicants within three to four hours.

“We know that this can be a stressful time for prospective students and their families,” the school said in a public statement. “The University at Buffalo deeply regrets this unfortunate error in communication.”

The students who were mistakenly emailed are still under review for admission.