a) Find a large reputable law firm and tell them to find me in 40 years.
b) Write some kind of distributed agent, a virus if you will, that learns about new communication media, runtime platforms, free hosting options for its code, etc. It has one goal: Keep track of my identity until the time comes and then hit me with the message on all channels it knows at the time.
That would be very difficult but not impossible I think. Yes, the internet may be long gone, but it's very unlikely that another platform like the internet would emerge without a very long period of transition and lots of interoperability giving the agent time to pick it up.
But what may be the downfall of such an agent is any change in the legal system that bans all anonymity on the net. One day, no code of any sort might be a allowed to communicate without using some kind of electronic signature.
Pay another $1000 to dig a hole in the school yard and put a proper decorative cover on the thing so people remember to dig it out when the time comes.
// Prepay for 40 years, leave the message in the box, forget the lockets. The bank will chase your for an extension for the rental of the box.
Far from foolproof but if you're already relying on a deposit box ...