我的代码又出错错错错了!

请问哪位大神能拯救一下?

# noinspection PyUnresolvedReferences
from O365 import Account, message, connection
from time import sleep

credentials = ('9c421bc5-483a-416a-ba2a-300ca6325d55', '应用机密,已隐藏')
a = 1
i = 0
email_adr = input('\nYou will send email to \n ')
subject = input('\n subject: ')
text = input('\nBody: ')
times = int(input('\nHow many times?\n'))+1

account = Account(credentials)
while i < times:
    m = account.new_message()
    m.to.add(email_adr)
    m.subject = subject
    m.body = text
    m.send()
    i = i + 1
    sleep(0.1)
    print("OK" + str(i))

这是一个自动发送邮件的简易程序,现在问题出在这:

  • 无法发送
  • 发送次数不对
    我如果使times为1,程序就会发送两次,为2,发送三次,以此类推,请问哪位大神能帮我看看?
    主要是我看不懂自己写的代码了
    @九亿少男的兄弟

你可能感兴趣的:(求助,REST,API)