I'm not sure if this is what you're asking, but you can send a PM from code like this:
Code:
// Set these like you want
$title = "PM title";
$message = "PM message";
$touserid = id;
$fromuserid = id;
$touserinfo = fetch_userinfo($touserid);
$fromuserinfo = fetch_userinfo($fromuserid);
$pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_SILENT);
$pmdm->set_info('savecopy', false);
$pmdm->set_info('receipt', false);
$pmdm->set_info('cantrackpm', false);
$pmdm->set_info('forward', false);
$pmdm->overridequota = true;
$pmdm->setr('title', $title);
$pmdm->setr('message', $message);
$pmdm->set('dateline', TIMENOW);
$pmdm->set('fromuserid', $fromuserid);
$pmdm->set('fromusername', $fromuserinfo['username']);
$pmdm->set_recipients($touserinfo['username'], $fromuserinfo['permissions'], 'cc');
$pmdm->pre_save();
if (!$pmdm->errors)
$pmdm->save();