What is so tricky about the trains from Cannes to Montpellier?
There are direct trains departing Cannes at 8:26, 12:27, 15:58, taking about 4 hours (all being trains from Nice to Bordeaux). At least between 12:00 and 18:00, there are several other connections with one or two changes and travel times between 4 and 5 hours. Be aware that if you change from a TGV to a regional train in Avignon (or vice versa), you have to plan a 10 minute bus trip between the two different stations "Avignon TGV" and "Avignon Centre".
Or is your question something completely else? You could easily have found this on any online train schedule search engine.