Rebuild Mail mailboxes?

Is it possible for an Applescript to rebuild a Mail.app mailbox? I have a script to get the messages in my inbox. However, if I delete a message from my inbox, and then run the script again, that deleted message will still show up, unless and until I go to Mail and rebuild the mailboxes. I’ve looked through the Mail dictionary and haven’t found anything useful that I recognize. I’m fairly newbie.

Thanks,

Jessi