如何解决如何在脚本中添加身份验证步骤?
我有一个脚本,在该脚本下,我希望安排每天通过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
解决方法
您不能-对于MFA,即使将凭据存储在密钥环中(仅处理基本凭据)也无法执行任何操作。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。