The two-envelope problem (or exchange problem) is one of maximizing the payoff in choosing between two values, given an observation of only one. This paradigm is of interest in a range of fields from engineering to mathematical finance, as it is now known that the payoff can be increased by exploiting a form of information asymmetry. Here, we consider a version of the ‘two-envelope game’ where the envelopes’ contents are governed by a continuous positive random variable. While the optimal switching strategy is known and deterministic once an envelope has been opened, it is not necessarily optimal when the content's distribution is unknown. A useful alternative in this case may be to use a switching strategy that depends randomly on the observed value in the opened envelope. This approach can lead to a gain when compared with never switching. Here, we quantify the gain owing to such conditional randomized switching when the random variable has a generalized negative exponential distribution, and compare this to the optimal switching strategy. We also show that a randomized strategy may be advantageous when the distribution of the envelope's contents is unknown, since it can always lead to a gain.