In this research, headspace solid phase microextraction technique coupled with electrospray ionization ion mobility spectrometry (ESI-IMS), for the first time. The proposed method has been applied for the extraction and determination of venlafaxine in the biological samples such as urine and plasma. A desorption chamber, as interface, was constructed for online connection of SPME technique to ESI-IMS. Analyte was desorbed by electrospray solvent and entered into the electrospray needle. The solid-phase microextraction (SPME) fiber coated with polypyrrole/sol–gel composite was prepared using a three-electrode electrochemical system and directly deposited on a stainless steel wire by applying a constant potential (1.2 V for 1000 s). The effect of different parameters including extraction time, temperature, pH and ionic strength were investigated and optimized. Under the optimized conditions, calibration curves were plotted indicating the linear dynamic range of 0.5-50, 1-85, and 20-1000 ?g/L, for standard water, spiked urine and spiked plasma samples, respectively. The relative standard deviation for the drug was less than 11% and the detection limits 0.2, 0.6, 11 ?g/L, was obtained for the drug extracted from water, spiked urine and spiked plasma, respectively. The relative recoveries obtained were 80% and 93% for spiked urine and plasma samples, respectively. Finally, some real samples of urine and plasma were analyzed and the obtained results reveal the capability of the proposed method for venlafaxine analysis in biological matrices.