### Instantiation Example
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/docs/source/quickstart.md
Instantiate OutlookAccount objects with access tokens.
```python
from pyOutlook import OutlookAccount
account_one = OutlookAccount('token 1')
account_two = OutlookAccount('token 2')
```
--------------------------------
### Contacts Example
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/docs/source/quickstart.md
Access the sender's name from a message.
```python
message = account.inbox()[0]
message.sender.name
>>> 'Dude'
```
--------------------------------
### Sending Emails - Message Class
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/docs/source/quickstart.md
Create a Message instance, attach content, and send.
```python
from pyOutlook import *
# or from pyOutlook.core.message import Message
account = OutlookAccount('token')
message = Message(account, 'A body', 'A subject', [Contact('to@email.com')])
message.attach(bytes('some bytes', 'utf-8'), 'bytes.txt')
message.send()
```
--------------------------------
### Install using pip
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/docs/source/installation.md
The recommended way to install pyOutlook is using pip.
```bash
pip install pyOutlook
```
--------------------------------
### Sending Emails - send_email() Method
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/docs/source/quickstart.md
Send an email using the send_email() method with all arguments upfront.
```python
account_one.send_email(
to=[Contact('myemail@domain.com')],
# or to=['myemail@domain.com')]
subject='Hey there',
body="I'm sending an email through Python.
Best,
Me",
)
```
--------------------------------
### Sending Emails - new_email() Method
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/docs/source/quickstart.md
Create and send a new email using the new_email() method.
```python
body = 'I\'m sending an email through Python.
Best,
Me'
email = account.new_email(body=body, subject='Hey there', to=Contact('myemail@domain.com'))
email.sender = Contact('some_other_account@email.com')
email.send()
```
--------------------------------
### Retrieving Emails
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/docs/source/quickstart.md
Retrieve emails from the inbox and access message body.
```python
inbox = account.inbox()
inbox[0].body
>>> 'A very fine body'
```
--------------------------------
### Sending Emails - Using new_email()
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Example of creating a Message instance, altering it, and sending it.
```python
from pyOutlook import *
account = OutlookAccount('')
test_email = account.new_email('This is a test body.
Best,
John Smith', 'This is a test subject', [Contact('anEmailAccount@gmail.com')])
test_email.attach('FILE_BYTES_HERE', 'FileName.pdf')
test_email.send()
```
--------------------------------
### Sending Emails - Using send_email()
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Example of sending an email by passing common parameters directly to send_email().
```python
from pyOutlook import *
account = OutlookAccount('')
account.send_email(
"I'm sending an email through Python.
Best,
Me",
'A subject',
to=['myemail@domain.com'],
# or to=[Contact('myemail@domain.com']
)
```
--------------------------------
### Folders - get_folder_by_id(folder_id)
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Getting a Folder object using its ID.
```python
from pyOutlook import *
account = OutlookAccount('')
folder = account.get_folder_by_id('id')
print(folder.name)
>>> 'My Folder'
```
--------------------------------
### Forwarding an Email
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/docs/source/pyOutlook.md
Examples demonstrating how to forward an email to specified recipients, with and without an additional comment.
```python
>>> john = Contact('john.doe@domain.com')
>>> betsy = Contact('betsy.donalds@domain.com')
>>> email = Message()
>>> email.forward([john, betsy])
>>> email.forward([john], 'Hey John')
```
--------------------------------
### Folders - get_folder_by_id(folder_id) with 'well known' folder name
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Getting a Folder object using a 'well known' folder name.
```python
from pyOutlook import *
account = OutlookAccount('')
folder = account.get_folder_by_id('Drafts')
print(folder.name)
>>> 'Drafts'
```
--------------------------------
### Instantiation
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Creates an instance of OutlookAccount, requiring an OAuth access token. The access token can be updated if refreshed.
```python
from pyOutlook import *
token = 'OAuth Access Token Here'
my_account = OutlookAccount(token)
# If our token is refreshed, or to ensure that the latest token is saved prior to calling a method.
my_account.access_token = 'new access token'
```
--------------------------------
### The Folder Object - move_into(destination_folder)
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Moving a folder into a new destination folder.
```python
from pyOutlook import *
account = OutlookAccount('')
folder = account.get_folders()[0]
folder_1 = account.get_folders()[1]
folder.move_into(folder_1)
```
--------------------------------
### The Folder Object - create_child_folder(new_folder_name)
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Creating a new folder within an existing folder.
```python
from pyOutlook import *
account = OutlookAccount('')
folder = account.get_folders()[0]
new_folder = folder.create_child_folder('New Folder')
new_folder.unread_count
>>> 0
```
--------------------------------
### Folders - get_folders()
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Retrieving a list of Folder objects representing each folder in the user's account.
```python
from pyOutlook import *
account = OutlookAccount('')
folder = account.get_folders()[0]
print(folder.name)
>>> 'Inbox'
```
--------------------------------
### The Folder Object - copy(destination_folder)
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Copying a folder and its contents to a designated folder.
```python
from pyOutlook import *
account = OutlookAccount('')
folder = account.get_folders()[0]
folder_1 = account.get_folders()[1]
folder.copy_into(folder_1)
```
--------------------------------
### The Folder Object - get_subfolders()
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Retrieving all child Folders within a given Folder.
```python
for subfolder in folder.get_subfolders():
print(subfolder.name)
>>> 'My New Folder v2'
>>> 'Some Other Folder'
```
--------------------------------
### Moving a Message (move_to*)
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Moves a message to another folder using specific methods for default folders or a general method for custom folders by ID or Folder instance.
```python
from pyOutlook import *
account = OutlookAccount('')
message = Message()
message.move_to_inbox()
message.move_to_deleted()
message.move_to_drafts()
message.move_to('my_folder_id')
folders = account.get_folders()
message.move_to(folders[0])
```
--------------------------------
### Replying to All Recipients (reply_all)
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Responds to all recipients of an email with an appended comment.
```python
from pyOutlook import *
account = OutlookAccount('')
email = account.get_message(id)
email.reply_all('I am replying to everyone, which will likely annoy 9/10 of those who receive this')
```
--------------------------------
### Retrieving a Specific Message (get_message)
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Retrieves the information for a message matching the provided ID.
```python
from pyOutlook import *
account = OutlookAccount('')
email = account.get_message('message_id')
print(email.body)
```
--------------------------------
### Retrieving Messages (get_messages)
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Retrieves the five most recent emails, returning a list of Message objects. Optionally specify the page of results to retrieve.
```python
from pyOutlook import *
account = OutlookAccount('')
account.get_messages()
account.get_messages(2)
```
--------------------------------
### The Folder Object - rename(new_folder_name)
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Renaming a folder in Outlook.
```python
from pyOutlook import *
account = OutlookAccount('')
folder = my_account.get_folders()[0]
folder = folder.rename('My New Folder v2')
folder.name
>>> 'My New Folder v2'
```
--------------------------------
### Setting and Retrieving Read Status
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/docs/source/pyOutlook.md
Demonstrates how to check and set the read status of an email message.
```python
>>> message = Message()
>>> message.is_read
>>> False
>>> message.is_read = True
```
--------------------------------
### The Folder Object - delete()
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Deleting a folder in Outlook.
```python
from pyOutlook import *
account = OutlookAccount('')
folder = account.get_folders()[0]
folder.delete()
# and now it doesn't exist
```
--------------------------------
### Replying to a Message (reply)
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Responds to the sender of an email with an appended comment.
```python
from pyOutlook import *
account = OutlookAccount('')
email = account.get_message(id)
email.reply('That was a nice email Lisa')
```
--------------------------------
### Forwarding a Message (forward)
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Forwards a message to a list of recipients with an optional comment.
```python
from pyOutlook import *
account = OutlookAccount('')
email = account.get_message('id')
email.forward([Contact('John.Adams@domain.com'), Contact('Nice.Guy@domain.com')])
email.forward(['John.Smith@domain.com'], 'Read the message below')
```
--------------------------------
### Accessing Parent Folder Information
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/docs/source/pyOutlook.md
Demonstrates how to retrieve the parent folder of a message and access its properties like unread count.
```python
>>> from pyOutlook import *
>>> account = OutlookAccount('')
>>> message = account.get_messages()[0]
>>> message.parent_folder
Inbox
>>> message.parent_folder.unread_count
19
```
--------------------------------
### Retrieving Inbox Messages (inbox)
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Retrieves the ten most recent messages in the inbox, ignoring messages in other folders.
```python
from pyOutlook import *
account = OutlookAccount('')
account.inbox()
```
--------------------------------
### Deleting a Message (delete)
Source: https://gitlab.com/jensastrup/pyoutlook/-/blob/master/README.md
Deletes the email. The email will still be present in the user's 'Deleted Items' folder.
```python
from pyOutlook import *
account = OutlookAccount('')
message = account.inbox()[0]
message.delete()
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.