from exchangelib import Account, CalendarItem, Message, Mailbox, FileAttachment, HTMLBody
from exchangelib.items import SEND_ONLY_TO_ALL, SEND_ONLY_TO_CHANGED
from exchangelib.properties import DistinguishedFolderId
a = Account(...)
item = CalendarItem(folder=a.calendar, subject='foo')
item.save()
item.save(send_meeting_invitations=SEND_ONLY_TO_ALL)
item.subject = 'bar'
print(CalendarItem.FIELDS)
item.save()
item.save(update_fields=['subject'])
item.save(send_meeting_invitations=SEND_ONLY_TO_CHANGED)
item.delete()
item.delete(send_meeting_cancellations=SEND_ONLY_TO_ALL)
item.soft_delete()
item.move_to_trash()
item.move(a.trash)
item.copy(a.trash)
item.archive(DistinguishedFolderId('inbox'))
m = Message(
account=a,
subject='Daily motivation',
body='All bodies are beautiful',
to_recipients=[
Mailbox(email_address='anne@example.com'),
Mailbox(email_address='bob@example.com'),
],
cc_recipients=['carl@example.com', 'denice@example.com'],
bcc_recipients=[
Mailbox(email_address='erik@example.com'),
'felicity@example.com',
],
)
m.send()
m = Message(
account=a,
folder=a.sent,
subject='Daily motivation',
body='All bodies are beautiful',
to_recipients=[Mailbox(email_address='anne@example.com')]
)
m.send_and_save()
m = a.sent.get(subject='Daily motivation')
m.reply(
subject='Re: Daily motivation',
body='I agree',
to_recipients=['carl@example.com', 'denice@example.com']
)
m.reply_all(subject='Re: Daily motivation', body='I agree')
m.forward(
subject='Fwd: Daily motivation',
body='Hey, look at this!',
to_recipients=['carl@example.com', 'denice@example.com']
)
forward_draft = m.create_forward(
subject='Fwd: Daily motivation',
body='Hey, look at this!',
to_recipients=['carl@example.com', 'denice@example.com']
).save(a.drafts)
forward_draft.reply_to = ['erik@example.com']
forward_draft.attach(FileAttachment(name='my_file.txt', content='hello world'.encode('utf-8')))
forward_draft.send()
item.body = HTMLBody('<html><body>Hello happy <blink>OWA user!</blink></body></html>')