使用python从Microsoft Outlook检索忙/闲状态 [英] Retrieving free/busy status from microsoft outlook using python

查看:137
本文介绍了使用python从Microsoft Outlook检索忙/闲状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用python语言从Outlook日历中检索特定人的忙/闲状态.

I'm trying to retrieving free/busy status from outlook calender for particular person using python language.

这是我的代码.

import win32com.client

obj_outlook = win32com.client.Dispatch('Outlook.Application')
obj_Namespace = obj_outlook.GetNamespace("MAPI")
obj_Recipient = obj_Namespace.CreateRecipient("someone@domain.com")
str_Free_Busy_Data = obj_Recipient.FreeBusy("11-11-2013", 11)
print str_Free_Busy_Data

但是我遇到了错误:

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    str_Free_Busy_Data = obj_Recipient.FreeBusy("11-11-2013", 11)
  File "<COMObject CreateRecipient>", line 4, in FreeBusy
TypeError: an integer is required

所以我的问题是Recipient.FreeBusy()方法带有两个必填参数,开始日期和持续时间.在这里11是持续时间,它是一个整数.那么,为什么python无法在此处识别整数参数并返回TypeError.

So my question is Recipient.FreeBusy() method takes two mandatory arguments, Start Date and duration. Here 11 is the duration, which is an Integer. So why python is not able to identify the integer argument here and returning an TypeError.

如果我做错了任何事情,请帮助我(我仍然是python世界中的新手).

Please help me in case I have done anything wrong (I'm still a newbie in python world).

谢谢.

推荐答案

我在MSDN中查找了该方法.

I looked up the method in MSDN.

该方法的语法带有3个参数.

The syntax for the method takes 3 arguments.

string FreeBusy(
DateTime Start,
int MinPerChar,
Object CompleteFormat

)

问题在于您要将字符串传递给DateTime参数.相反,您需要在代码中导入datetime库,并使用date参数.

The issue is that you're passing a string to the DateTime parameter. Instead you need to import the datetime library in your code and use a date parameter.

因此,在代码的开头,请尝试此操作.

So, at the start of your code, try this.

import datetime

#Then declare the my_date variable as datetime.date.

my_date = datetime.date(2013,11,23)
str_Free_Busy_Data = obj_Recipient.FreeBusy(my_date, 11)

这篇关于使用python从Microsoft Outlook检索忙/闲状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆