Summary Lost circulation during the drilling of fractured formations is one of the most challenging engineering problems. Shape memory polymers (SMPs) have been used as lost circulation materials, but most of them are not resistant to high temperatures. In this study, a high-temperature-resistant thermal shape memory epoxy resin (SME) was synthesized by conducting an orthogonal experiment using the glass transition temperature (Tg) as an index. The Tg of the SME synthesized by using the optimum formula was 124℃. This SME had good thermal stability, and its compression and tension stresses were 94.2 and 58.8 MPa, respectively. In addition, the thickness swelling ratio (Rrc) of the SME was optimized by performing another orthogonal experiment, and the Rrc of the SME prepared by using the optimized formulation (OSME) was 78.8%. The OSME did not swell at 25–150℃ in water, brine, or base fluid. The total size reduction percentage of the OSME was 1.7% after aging at 150℃, whereas that of a nutshell was 10.7%, indicating that OSME particles had better compression and temperature-resistance performance. The shape memory ratio (Rc) of the OSME was 6, 70, and 100% at 80, 120, and 125℃ after being heated for 50 minutes, respectively, and it was fully activated in 5 minutes at 150℃. The breakthrough pressure of the plugging mud with or without the OSME was 15 MPa at 25, 80, 120, and 150℃ when plugging the wedge fracture model with an inlet/outlet width of 3/1 mm. However, when plugging the wedge fracture model with an inlet/outlet width of 5/2 mm, the plugging slurry with the OSME could withstand a pressure of 3, 5, and 15 MPa at 80, 120, and 150℃, respectively, and the plugging mud with conventional lost circulation materials could bear a pressure of below 3 MPa at 80, 120, and 150℃. These results indicated that the OSME had good plugging and thermosensitive performance. OSME particles matched better with the fracture size, owing to their elastic and shape memory performance at above Tg. They migrated and bridged in fractures, aggregated and filled the pore space with other lost circulation materials, and formed a dense plugging layer at above Tg. Thus, the synthesized SME is a promising material for plugging high-temperature fracture formations while drilling.