"So when they forgot that which they were reminded of," meaning: they denied what the Messengers brought to them.
"We opened to them the gates of everything," of provisions, "until, when they rejoiced in that which they were given," meaning: that which they were granted, "We seized them suddenly," meaning: with the punishment unexpectedly, "and thereupon they were in despair," meaning they despaired.