Example #1
0
import datetime
import logging

from O365 import Account

from wu.seal.emailtool.EmailTemplate import obtainRequestPublishEmailHtmlBody, obtain_table_items, \
    obtain_publish_notify_email_html_body
from wu.seal.emailtool.Utils import Utils

logger = logging.getLogger('Email')
logging.basicConfig(level=logging.INFO)

credentials = ('4a1ce983-de30-4631-ac5c-bfc410e64244',
               'jdejIOQMAJ0:;iknK0243):')

account = Account(credentials=('4a1ce983-de30-4631-ac5c-bfc410e64244',
                               'jdejIOQMAJ0:;iknK0243):'))

# 下面两行代表授权登录过程,有效期只有90天


def printInboxMessage():
    mailbox = account.mailbox()
    inbox = mailbox.inbox_folder()
    for message in inbox.get_messages():
        logger.info(message)
        logger.info(message.sender)


def authontic_work_flow():
    result = account.authenticate(scopes=['basic', 'message_all'])
    info = '成功' if result else '失败'
Example #2
0
# avoid ssl error
import urllib3
urllib3.disable_warnings()

# import python-o365
import sys
sys.path.insert(0, './python-o365')

import datetime as dt
from O365 import Account
import password_list

# outlook
client_id = password_list.client_id
client_secret = password_list.client_secret
account = Account((client_id, client_secret))

if not account.is_authenticated:
    account.authenticate(scopes=['basic', 'calendar_all'])

schedule = account.schedule()
calendar = schedule.list_calendars()

print(calendar)

Example #3
0
from O365 import Account
import yaml

conf = yaml.load(open('conf/credentials.yml'))
credentials = (conf['client_id'], conf['client_secret'])

account = Account(credentials)  # the default protocol will be Microsoft Graph
account.authenticate(scopes=['basic', 'message_all', 'offline_access'])
Example #4
0
def read_txt(name):
    data = ""
    with open(name, 'r') as file:
        data = file.read().replace('\n', '')
    return data


login_file = open('login_info.txt', 'r')
client_id = login_file.readline()[:-1]
client_secret = login_file.readline()[:-1]

credentials = (client_id, client_secret)

scopes = ['message_all']

account = Account(credentials)
if account.authenticate(scopes=['https://graph.microsoft.com/Mail.Send']):
    print('Authenticated!')

    main_text = read_txt('main_text.txt')
    confintality_notice = read_txt('confintality_notice.txt')
    subject = read_txt('subject.txt')
    str_from = read_txt('from.txt')
    #add loop here if you want to sent to many
    to = '*****@*****.**'
    m = account.new_message()
    m.attachments.add('1.png')
    att = m.attachments[0]
    att.is_inline = True
    att.content_id = 'image.png'
    m.attachments.add('2.png')
Example #5
0
 def setup_class(self):
     credentials = ("client id", "client secret")
     self.account = Account(credentials)
     self.teams = account.teams()