Mehdavi
Mehdavi

Reputation: 41

Labels creation in gmail account using mailcore2

I am building an ios app in which I am presenting emails from the user's gmail inbox on a UITableView. Now I have gotten a new requirement i.e. to create labels (through code) and move the selected emails from inbox to those labels (through code). I am supposed to achieve this task using mailcore 2 . I have no idea how to go with it, need your help plz

Upvotes: 1

Views: 564

Answers (1)

CodaFi
CodaFi

Reputation: 43330

You can create folders with -[MCOIMAPSession createFolderOperation:] which takes the path of the folder relative to the root path of the server and delimited with the default delimiter of that account (which can be fetched with an MCOIMAPNamespaceOperation). To move emails into that folder destructively (all the messages are removed from the old and put into the new), you can use -[MCOIMAPSession copyMessagesOperationWithFolder:uids:destFolder:], then call -[MCOIMAPSession storeFlagsOperationWithFolder:uids:kind:flags:] passing along the old folder, the UIDs you just copied, and MCOIMAPStoreFlagsRequestKindAdd as the kind, and MCOMessageFlagDeleted as the flag. Non-destructive requests just involve a copy operation.

To add labels to a message, use -[MCOIMAPSession storeLabelsOperationWithFolder:uids:kind:labels:] with an array of strings for the labels to apply.

Upvotes: 1

Related Questions