Soap and Sugar
Nearly anything will attract flies -- especially rotting foods. However, like ants, flies are also attracted to sugary substances. A simple bowl filled with sugar and soap will act as a fly attractant. For this particular setup, the soap acts as the trap, while the sugar does the attracting. This solution in a bowl is enough to act as a fly trap. When the soap gets on the wings, the flies will lose their ability to fly away and will subsequently become trapped in the liquid solution.
Rotten Fruit and Meat
An alternative solution for attracting flies is to use fruit. Let fresh fruit (the type doesn̵7;t matter) rot, and then set it up in the bottom of your homemade trap or near the area where you want to attract flies. Alternatively, meat can be used to attract flies. Like rotten fruit, set the meat at the bottom of a trap; however, beware of placing the meat anywhere near the ground as it may act as an attractant for other critters as well.
Syrups and Mixtures
Syrup -- composed of mostly sugar -- also works extremely well to attract flies. Combine equal parts of syrup and vinegar and place the mixture in the bottom of a homemade trap. Alternatively, fruit juices or soda can be substituted for the syrup. Placing this mixture in a can, jug or jar in a fly-prone area can help to eliminate flies.
Professional Attractants
If all else fails, there are several fly-traps with mixtures that act as bait. Fly-catchers, such as Final Flight, use odors that include mate-attracting smells. The Z-9 Fly Attractant uses synthetic pheromones. Other traps -- such as the Wet Tablet -- are designed to last for several months, releasing lower-intensity odors.