Mesh quality is a major factor affecting the structure of computational fluid dynamics (CFD) calculations. Traditional mesh quality evaluation is based on the geometric factors of the mesh cells and does not effectively take into account the defects caused by the integrity of the mesh. Ensuring the generated meshes are of sufficient quality for numerical simulation requires considerable intervention by CFD professionals. In this paper, a Transformer-based network for automatic mesh quality evaluation (Gridformer), which translates the mesh quality evaluation into an image classification problem, is proposed. By comparing different mesh features, we selected the three features that highly influence mesh quality, providing reliability and interpretability for feature extraction work. To validate the effectiveness of Gridformer, we conduct experiments on the NACA-Market dataset. The experimental results demonstrate that Gridformer can automatically identify mesh integrity quality defects and has advantages in computational efficiency and prediction accuracy compared to widely used neural networks. Furthermore, a complete workflow for automatic generation of high-quality meshes based on Gridformer was established to facilitate automated mesh generation. This workflow can produce a high-quality mesh with a low-quality mesh input through automatic evaluation and optimization cycles. The preliminary implementation of automated mesh generation proves the versatility of Gridformer.