This needs immediate medical attention; I'll attempt to dissect what you just said.
• "Band-aid-like surgical items... partially black or green":
■ This is not just old gauze changing color from digestive juices. The black and green coloration strongly suggests that the material is necrotic (dead tissue) and infected.
■ It is likely that this material is the core of a chronic abscess or infection, and the discoloration is from bacteria and decaying tissue.
■ This is a sign of a significant, active infection that your body has been unable to clear.
• "Every two or three months":
■ This cyclical pattern happens for a chronic, walled-off infection.
■ The body attempts to contain the infection and foreign material, building up pus and inflammatory fluid until the pressure is so great that it forcibly drains through the path of least resistance — probably in your case, through a fistula into your intestine and out your stoma.
■ Once it drains, you may feel temporary relief before the cycle repeats.
• "I get a little bit of a stomach ache before this happens":
■ This is a key symptom that ties everything together. ■ The stomach ache is likely due to the increased inflammation and pressure building up in your abdomen before the material is expelled.
■ It is a direct signal from your body that an inflammatory event is occurring.
• A likely scenario is you almost certainly have a retained surgical foreign body (a piece of sponge, gauze, or possibly even a failed prosthetic mesh) from a surgery.
• This foreign material has acted as a constant irritant and a breeding ground for bacteria, leading to a chronic intra-abdominal abscess. This abscess has formed a fistula (an abnormal tunnel) that connects it to a loop of your small intestine.
• Every few months, the abscess fills up, causes you pain, and then ruptures, draining its infected contents (including pieces of the decaying foreign material) into your intestine and out through your ileostomy.
• This is quite serious because each one of these episodes is a small, uncontrolled release of bacteria into your system. It could escalate into a life-threatening full-body infection at any time (sepsis).
• I am surprised your doctors did not order a CT scan. You should immediately contact your surgeon, and if you can't reach your surgeon, go to the ER. Tell your surgeon/ER doctor: "I have an ileostomy, and for some time, I have been periodically passing pieces of what looks like old surgical gauze or sponge that are black and green. This is accompanied by abdominal pain. I am concerned about a retained foreign body and an abscess." Bring the 17 pieces you have retained to show them.
• The doctor will almost certainly order an urgent CT scan of your abdomen and pelvis with contrast dye to try to locate the source of the problem, the abscess, and the fistula. If a CT scan is not ordered, you should insist on one.
This is my last post, and I pray that you take immediate steps to take care of this. You will get plenty of help and support from others on this site.