Message - dylandoamaral/ggmail GitHub Wiki

What is a message ?

A Message is the object representing an email.

Manage flags of a message

All messages have flags to describe them. As an example if you answer to a message, the message will have the flag \Answered.

From a message you can check the presence of a flag, add a flag or remove a flag. Here is the list of possible actions:

message.is_answered() # Check if the message has the flag \Answered
message.answer() # Add the flag \Answered
message.unanswer() # Remove the flag \Answered

message.is_deleted() # Check if the message has the flag \Deleted
message.delete() # Add the flag \Deleted
message.undelete() # Remove the flag \Deleted

message.is_draft() # Check if the message has the flag \Draft
message.draft() # Add the flag \Draft
message.undraft() # Remove the flag \Draft

message.is_starred() # Check if the message has the flag \Flagged
message.star() # Add the flag \Flagged
message.unstar() # Remove the flag \Flagged

message.is_seen() # Check if the message has the flag \Seen
message.seen() # Add the flag \Seen
message.unseen() # Remove the flag \Seen

Move a message

You can move a message by copying or by moving it. If you move it, it will copy it and add a delete marker to the source message. If you want it to disapear, you will have to set with_expunge=True to the function.

mailbox = mailbox.inbox()

message.copy(mailbox)
message.move(mailbox) # The source message will not disappear but a deleted flag will be added
message.move(mailbox, with_expunge=True) # The source message will disappear