He shouldn't write directly to the judge. Any communication with the court should go through his lawyer, and should be copied to the prosecutor's office. If he isn't represented, he may wish to instead express his gratitude to the probation officer who made the recommendation for treatment.

