In a deep baking dish, arrange alternate layers of ham and apples. Sprinkle each layer with onion and seasonings. Moisten each layer with bouillon. Cover this with a thick layer of mashed potatoes. Brush the potato peaks with melted butter. Bake at 325 degrees for 1 1/2 to 2 hours or until the ham is thoroughly heated and the potato peaks are browned.