Arrivals from Heathrow can travel by Heathrow Express which is an expensive and time consuming service.
To save yourself time and money, use the Picadilly line direct from Heathrow to Hammersmith, then cross the platform to the East bound district line direct to Barking which saves you an hour and fourteen pounds.

Arrivals from Gatwick, take the Gatwick express rail service to Victoria Station, then take the Underground (Subway) head to the District Line going to either Barking or Upminster going East.

UK Rail card are NOT accepted by London Underground (Subway) they are STRICTLY for overhead rail services which DO NOT service the inner London area, London Underground (Subway) offer their own travel cards Daily, Weekly and Monthly which ARE accepted by the overhead rail sevice WITHIN the London Underground service area.
Save yourself some money and buy your Travel Cards in the UK as you may end up paying for something that you cannot use.
If you are a family or a group London Underground (Subway) and Transport for London (bus) offer discounted family or group ticket.

To pre-plan all of your journeys go to the Transport for London web site.