【问题标题】:How can I add the authentication step in my script?如何在我的脚本中添加身份验证步骤?
【发布时间】:2021-01-01 13:40:36
【问题描述】:

我有一个脚本,我想安排每天通过 SQL Server 运行它并将日历事件存储到数据库,但问题是我需要打开 Outlook 才能运行此脚本,我该如何在脚本中添加我的凭据,这样我就不必打开 Outlook 并在不保持 Outlook 打开的情况下运行脚本?谢谢

import win32com.client, datetime
from datetime import date
from dateutil.parser import *
import calendar
import pandas as pd
import pyodbc

Outlook = win32com.client.Dispatch("Outlook.Application")
ns = Outlook.GetNamespace("MAPI")

Item = Outlook.CreateItem ( 1 )
Recip = Item.Recipients.Add ( 'Corporate Master Calendar' )

appts = ns.GetSharedDefaultFolder(Recip,9).Items
appts.Sort("[Start]")
appts.IncludeRecurrences = "False"

eoy=date(date.today().year, 12, 31)
eoy=eoy.strftime("%m/%d/%Y")
begin = date.today()
begin = begin.strftime("%m/%d/%Y")

appts = appts.Restrict("[Start] >= '" +begin+ "' AND [Start] <= '" +eoy+ "'")

apptDict = {}
item = 0
for indx, a in enumerate(appts):
        organizer = str(a.Organizer)
        start = a.Start
        end = a.End
        subject = str(a.Subject)
        location = str(a.Location)
        categories = str(a.Categories)
        body=str(a.Body)
        itemid=str(a.GlobalAppointmentId)
        lmt=str(a.LastModificationTime)
        apptDict[item] = {"GlobalAppointmentId": itemid, "Organizer": organizer, "Subject": subject, "Location": location, "Start": start, "End": end, "Body": body,"Categories": categories, "LMT":lmt}
        item = item + 1

【问题讨论】:

    标签: python email outlook pywin32 win32com


    【解决方案1】:

    您不能 - 使用 MFA,即使将凭据存储在密钥环(仅处理基本凭据)中也无济于事。

    【讨论】:

    • 哦,不,谢谢你,但非常感谢你的回复
    猜你喜欢
    • 2021-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多