Firstly the HMRC are incredibly helpful on the phone - not at all like they're portrayed.
Secondly, 40p is the business rate per mile for the first 10,000 miles of business travel. Because you are BASED at A and HAVE to travel to B to work, provided you can back that up with evidence, you may well be able to claim.
While you're at it, look up Subsistence claims as well, as you can claim for meals provided your door-back to-door day is in excess of certain hours. I don't know your circumstances, but it's worth checking.
Best of luck either way.