Question: I have been using java mail to automate Gmail operations.
One of the operation is to delete mail and I use following for it -

```
message.setFlag(Flags.Flag.DELETED, true);

```

but doing so only pushes my mails to spam folder.

I am wondering if there is a straight way to delete mail permanently instead of deleting mail from "inbox" first and then searching mails in "spam " folder and deleting them.

Answer: 
You told that you are trying 

```
 message.setFlag(Flags.Flag.DELETED, true);

```

did you tried 
`folder.close(true);`
this will expunge all messages with DELETED flags.
Setting the flag to Flags.Flag.DELETED only marks the email as deleted.

You need to call 

folder.expunge();

to actually expunge those emails marked as deleted.