IMAP Gmail

Can anyone help? I’m trying to find the correct applescript language to access and delete spam from the spam folder in IMAP Gmail. I can delete the deleted items with script, but can’t find the correct language to get to the spam. Any ideas?