British Consul-General, Consul or Vice-Consul
A Consul-General, Consul or Vice-Consul who holds Her Majesty's Commission is entitled to the letters 'HM' before the appointment.
Other Consuls, Vice-Consuls and Consular Agents, appointed other than by the Crown, are known as the British Consul, Vice-Consul, etc, and do not have the prefix 'HM'.
An officer in charge of a Consular appointment, during the absence of the incumbent, takes for the time being the rank of the incumbent, but is addresses as 'The Acting British Consul-General, Consul', etc.
Consuls of the other Commonwealth countries are addressed as 'The Australian Consul', etc.
How to Style a Consul-General, Consul or Vice-Consul
The envelope for a Consul-General would be:
John H. Brown, Esq, CMG
The envelope for a Consul would be:
William Smith, Esq
The envelope for a British Consul would be:
William Jones, Esq
Otherwise it is correct to use 'Esquire' or an appropriate style.