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
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.
Related
Using IMAP, how can I figure out if a mailbox has been moved or deleted by another client?
The LIST command simply does not list a deleted mailbox any more.
Exactly. You have to remember what folders you know about. Next time you do a LIST, any that are missing have been deleted.
Additionally, you should be tracking every folder's UIDVALIDITY value. If it changes, that folder is not the same one you know about. It may have been renumbered, deleted and recreated, or deleted and replaced by a renamed folder.
In either case, you should dump any cached information you know about that folder.
There is not, in general, any way to track folders that have been renamed by another client. You can only detect that a folder is missing and there is a folder with a new name. IMAP simply does not provide enough information to correlate them. Tracking messages and folders across moves does not appear to have been a design goal of IMAP.
When retrieving folders list with Outlook REST API (beta endpoint)
https://outlook.office365.com/api/beta/me/MailFolders
I get the complete list of folders. But I also get some hidden/ignored folders that are not displayed in usual Outlook clients. I would like to ignore such folders as well.
I tried to forge a request using SingleExtendedProperty and PigTagAttributeHidden
https://outlook.office365.com/api/beta/me/MailFolders?$select=Id,DisplayName,ParentFolderId,ChildFolderCount,UnreadItemCount,TotalItemCount,SingleValueExtendedProperties&$expand=SingleValueExtendedProperties($filter=(PropertyId eq 'Boolean 0x10F4'))
In the results this property is always marked as false even for these "ignored" folders.
Is there another way or fix to achieve this?
I went through the folders reported, and none of them were hidden. Basically they fell into two categories:
System folders like Sync Issues and Conflicts. These aren't hidden, but OWA doesn't show them in it's folder view. OWA handles these specially. The suggestion for a REST app that wants to also handle these specially and not show them is to check the WellKnownName property. All of these have a constant value for that property, so they can be selectively filtered.
Add-in folders. These were created by a module extension add-in. They actually reside in a folder structure like:
/WebExtAddIns (Hidden)
|__/{GUID id of addin} (Hidden)
|__/{Name of module extension tab} (Visible)
The REST API includes the {Name of module extension tab} folder because it's marked visible, even though it's parent folder is hidden. I've reported this to our developers and we are investigating improving this scenario. In the meantime, you can filter these out by making sure that the ParentFolderId matches either the Id of another folder in the folder results OR the ParentFolderId of the Inbox folder.
We use extensively (from an application) in the Document List API the fact than a file / document can be assigned to more than one collection, in order to work in a similar way that labels. Has this been deprecated? At least from the web user interface, only one folder can be assigned to one file.
Working fine here and multiple collections can be successfully assigned.
Right click a file, Choose "Organise" and check the box next to each collection you want the document to be a part of.
Does anyone have some sample code demonstrating how to make a "file browser" view? I'd like to be able to navigate through directories and drill-down the sub-directories and see files located within the various folders. I want the user to be able to create new directories/files and even select an existing file. Is there sample code out there already available to do this?
I don't know about sample code, but this wouldn't be too complicated to achieve using NSFileManager and a UITableView.
You can obtain arrays of directory contents using the subpathsOfDirectoryAtPath:error and associated methods of a file manager. These arrays in turn can populate a UITableView. It would be fairly easy to put together a navigation controller that could display a series of table views showing a file hiearchy.
Bear in mind, however, that you'll only be able to access the directories inside your application sandbox, unless you're running on a jailbroken device.
The iOS programming guide says that
You should never present users with the list of files in this directory and ask them to decide what to do with those files. Instead, sort through the files programmatically and add files without prompting.
This is assuming you are trying to implement file browse feature for your documents directory.
I'm an author of FileExplorer which is a file browser for iOS and fulfills most of your requirements.
Here are some of the features of my control:
Possibility to choose files or/and directories if there is a need for that
Possiblity to remove files or/and directories if there is a need for that
Built-in search functionality
View Audio, Video, Image and PDF files.
Possibility to add support for any file type.
You can find my control here.
What I do now with Outlook:
I receive email orders for products. I select a single or multiple emails in Outlook (a single order can have multiple emails associated with it) and then switch to my Delphi coded OrderManager program and click "Import". It uses Outlook's COM automation interface to read the text of each message, parses and processes each one.
The question is, can I do this using Thunderbird instead? Does Thunderbird have a COM interface? I must be googling the wrong keywords because I haven't found anything yet.
Btw, I do have a version of my OrderManager that just reads the emails directly from my email server using Indy, but for several reasons I'd like to try to read them from Firefox.
Any suggestions, links to docs, or code samples will be greatly appreciated!
Check this link out.
You could write a C or C++ wrapper around XPCOM and then use that wrapper within Delphi.
There is also an open source XPCOM wrapper written in Delphi. You might want to check that out as well. Thanks Stijn for pointing that out.
Hope it helps.
You could also parse Thunderbird's mailbox files yourself.
From %APPDATA%\Thunderbird\profiles.ini, read where the profile folder is located (if there's more than one profile, look through sections Profile0..Profilen for the one that has the value Default=1)
Each subfolder of the Mail and/or ImapMail subfolders of the profile folder represents an account (Mail contains POP accounts, ImapMail contains IMAP accounts);
Look through all files whose names don't end with .dat or .msf, and whose contents start with 'From ' (F, r, o, m, and a space). Those are the mailbox files.
Every line that starts with 'FromĀ ' indicates a new message. Use the X-Mozilla-Status header to figure out whether the message is still valid, or whether it's been marked for deletion. (You can use the CDO.Message COM object to parse the message for you, if you want).
You should recurse for each subfolder ending on '.sbd', since that will contain that mailbox's subfolders (E.g. Inbox.sbd will contain the mail folders under the Inbox).
Be wary of file locking issues, however.