Lightly butter an 8-inch square baking dish and arrange 4 slices of the bread flat on the bottom. Cover each with equal amounts of cheese and ham, if desired. Top with the remaining bread.
Beat the eggs lightly in a small bowl and pour in the milk. Season with the salt and blend well. Pour over the sandwiches, cover and refrigerate for 1 hour.
Preheat the oven to 350 degrees F. Bake the sandwiches, uncovered, until lightly browned around the edges and set in the center, 40 to 45 minutes. Serve hot.