KNOXVILLE, Iowa – A soon-to-be grandmother killed at a gender-reveal party in Iowa was struck in the head by shrapnel after her family inadvertently created a "pipe bomb" to announce the impending baby news, authorities said.

Pamela Kreimeyer, 66, was killed on Saturday afternoon at her home in Knoxville, about 40 miles southeast of Des Moines, when the homemade gender-reveal contraption that contained gunpowder exploded, sending pieces of metal flying, according to authorities.

Kreimeyer died at the scene.

"The family got together for what they thought was going to be a happy event with no intent for anyone to get hurt. What ended up happening was that Pamela Kreimeyer, a wife, mother and grandmother, was killed by a piece of metal where a metal stand, gunpowder and colored powder were involved," Marion County Sheriff Jason Sandholdt said in a statement.

Kreimeyer and four family members, including her daughter-in-law who is expecting a baby, gathered outside her home to light a fuse to the makeshift explosive, according to an investigation by the sheriff's office, the Iowa State Fire Marshall's Office and the federal Bureau of Alcohol, Tobacco, Firearms and Explosives.

"Our investigation showed that members of the Kreimeyer family were experimenting with different types of explosive material on Friday and Saturday in an attempt to record a gender reveal that could be posted on social media for friends and family," according to a statement from the sheriff's office.

The deadly device was fashioned out of a metal tube welded to a metal base plate and had a hole drilled in the side of the tube for a fuse, the sheriff's office said. The tube was then filled with gunpowder and a colored powder and covered with a board.

"Tape was then wrapped over the top of the metal tubing, inadvertently creating a pipe bomb," the statement read. "Instead of the gunpowder shooting the powder out the top of the stand, the stand exploded sending metal pieces flying."

Pamela Kreimeyer was standing with family members about 45 feet from the device when it exploded and she was hit in the head by a piece of shrapnel, "causing instant death," according to the sheriff's office.

"It's believed that the projectile that struck the victim then continued another 144 yards through the air coming to rest in a field," according to the sheriff.

A man who answered the phone Sunday at the Kreimeyer home told ABC News that his wife was the woman killed, but declined further comment.

"This is a reminder that anytime someone mixes these things there is a high potential for serious injury or death; please do not take these unnecessary risks," Sandholdt said in his statement. "My condolences go out to the family."

An explosion set off at a gender-reveal party in Green Valley, Arizona, two years ago sparked the massive Sawmill Fire, which burned 47,000 acres in the Coronado National Forest.

In that incident, Dennis Dickey, 37, an off-duty U.S. Border Patrol agent, revealed his wife was carrying a boy when he used a high-powered rifle to shoot at a target causing it to explode with a blue substance, according to a statement by the U.S. Justice Department. Dickey had packed the target with the explosive substance Tannerite, according to the statement.

Dickey pleaded guilty in September 2018 to federal charges stemming from the Sawmill Fire. He was sentenced to five years probation and ordered to pay $8.1 million in restitution.