AFAIK, calling build_new_post should increase the relevant counts and add it to the index.
The code I would use is slightly different to yours ;
PHP Code:
$postforumid = 2;
$postforum = fetch_foruminfo($postforumid);
$post['title'] = "here is my catchy title";
$post['message'] = "some fabulous message.";
require_once('./includes/functions_newpost.php');
build_new_post('thread', $postforum , array(), array(), $newpost, $errors);
After calling this, the post and thread id's should be in $newpost['threadid'] and $newpost['postid'].