forked from O365/python-o365
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request O365#83 from drewstinnett/move_folders
Adding in operations to do more with folders
- Loading branch information
Showing
5 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import sys | ||
import getpass | ||
from O365 import Connection, FluentInbox | ||
|
||
|
||
def main(): | ||
if len(sys.argv) == 1: | ||
sys.stderr.write("Usage: %s BY VALUE\n" % sys.argv[0]) | ||
return 1 | ||
|
||
username = input("Username: ") | ||
password = getpass.getpass("Password: ") | ||
authentication = (username, password) | ||
Connection.login(*authentication) | ||
inbox = FluentInbox() | ||
|
||
print(inbox.get_folder(by=sys.argv[1], value=sys.argv[2])) | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import sys | ||
import getpass | ||
from O365 import Connection, FluentInbox | ||
|
||
|
||
def main(): | ||
username = input("Username: ") | ||
password = getpass.getpass("Password: ") | ||
authentication = (username, password) | ||
Connection.login(*authentication) | ||
inbox = FluentInbox() | ||
|
||
# If given arguments, treat them as folder_ids to use as parents | ||
if len(sys.argv) > 1: | ||
for folder_id in sys.argv[1:]: | ||
for folder in inbox.list_folders(parent_id=folder_id): | ||
print(folder['Id'], folder['DisplayName']) | ||
else: | ||
for folder in inbox.list_folders(): | ||
print(folder['Id'], folder['DisplayName']) | ||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import sys | ||
import getpass | ||
from O365 import Connection, FluentInbox | ||
|
||
|
||
def main(): | ||
if len(sys.argv) == 1: | ||
sys.stderr.write("Usage: %s 'subject to search for'\n" % sys.argv[0]) | ||
return 1 | ||
|
||
username = input("Username: ") | ||
password = getpass.getpass("Password: ") | ||
authentication = (username, password) | ||
Connection.login(*authentication) | ||
inbox = FluentInbox() | ||
|
||
trash_folder = inbox.get_folder(by='DisplayName', value='Trash') | ||
|
||
for message in inbox.search("Subject:%s" % sys.argv[1]).fetch(count=1): | ||
print(message.moveToFolder(trash_folder['Id'])) | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |