Sulfonium compounds can be synthesized from the reaction of dialkylsulfides with alkyl halides:
In the above reaction, the alkylation of a sulfide, the sulfur atom has two lone electron pairs. Using those lone pairs, the sulfide acts as a nucleophile, and attacks the carbon of iodomethane. At the same time, as part of a concerted nucleophilic substitution mechanism (SN2), the iodide leaving group comes off; this leaves a positively charged trimethylsulfonium ion. This cation is attracted to the negatively charged iodide, so the two form an ionic bond, giving trimethylsulfonium iodide.