Windows Outlook API:获取忙/闲状态

Windows Outlook API:获取忙/闲状态,windows,api,outlook,Windows,Api,Outlook,我四处寻找,但找不到答案。我不确定这是否可能,但似乎是这样 我基本上想把Outlook中的空闲/忙碌状态转换成C++程序。例如,我想检查我是否有约会,然后打印“空闲”或“忙”。当然,如果我也能得到约会的描述,那就太棒了 有没有更简单的方法? 任何教程或示例链接都将不胜感激 谢谢。我想这应该会有帮助。让我知道 我提供以下链接的内容:- 检查忙/闲状态 Exchange Server 2003-检查忙/闲状态 Before you send a meeting request, you can ch

我四处寻找,但找不到答案。我不确定这是否可能,但似乎是这样

我基本上想把Outlook中的空闲/忙碌状态转换成C++程序。例如,我想检查我是否有约会,然后打印“空闲”或“忙”。当然,如果我也能得到约会的描述,那就太棒了

有没有更简单的方法? 任何教程或示例链接都将不胜感激

谢谢。

我想这应该会有帮助。让我知道

我提供以下链接的内容:-

检查忙/闲状态

Exchange Server 2003-检查忙/闲状态

Before you send a meeting request, you can check an attendee's calendar to see when the attendee is available. The IAddressee.GetFreeBusy method returns a string of numbers that indicate the attendee's availability for a requested period of time.
Each number in the free/busy string represents an interval of time (every ½ hour in this example). Free time returns 0, Tentative returns 1, Busy returns 2, and Out of Office (OOF) returns 3. If appointments overlap, the highest number is returned. If no free/busy data is available for the interval, the value 4 is returned.
The following figure shows part of an attendee's calendar and the corresponding free/busy string.
The free/busy string for a part of an attendee's calendar
To get an attendee's free/busy status for a specific time, you can create an Addressee object and execute the IAddressee.GetFreeBusy method. You can also get the free/busy status for longer intervals and parse the string to find times the attendee is free.
Note  You must first call the IAddressee.CheckName method and resolve the addressee before you can use the IAddressee.GetFreeBusy method.
Note  An automated process in Microsoft® Exchange Server 2003 periodically updates the free/busy status of users. Microsoft Outlook® updates the free/busy status of Outlook users. Collaboration Data Objects (CDO) synchronizes the Outlook free/busy cache with free/busy information from CDO clients. The free/busy status is not updated immediately when a meeting is added to a user's calendar. By default, three months' worth of free/busy status is maintained in a system folder in the Exchange store.
This topic contains Microsoft Visual Basic®, Microsoft Visual C++®, Microsoft C#, and Visual Basic .NET code examples.
Visual Basic
The following example returns the free/busy status of the specified user:
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Library

' Note: It is recommended that all input parameters be validated when they are
' first obtained from the user or user interface.
Function GetFreeBusyString(strUserUPN As String, dtStartDate As Date, dtEndDate As Date, Interval As Integer) As String

    Dim iAddr    As New CDO.Addressee
    Dim freebusy As String
    Dim Info     As New ADSystemInfo

    iAddr.EmailAddress = strUserUPN
    If Not iAddr.CheckName("LDAP://" & Info.DomainDNSName) Then
        ' handle error
    End If

    'Get the free/busy status in Interval minute intervals from dtStartDate to dtEndDate
    freebusy = iAddr.GetFreeBusy(dtStartDate, dtEndDate, Interval)
    GetFreeBusyString = freebusy

End Function


C++
The following example returns the free/busy status of the specified user:
/*
 Assume that the following paths are in your
 INCLUDE path.
 %CommonProgramFiles%\system\ado
 %CommonProgramFiles%\microsoft shared\cdo
*/

#import <msado15.dll> no_namespace
#import <cdoex.dll> no_namespace
#include <iostream.h>

// Note: It is recommended that all input parameters be validated when they are
// first obtained from the user or user interface.
bstr_t getFreeBusyString( const bstr_t& userUPN, const bstr_t& domainDNSName, DATE startDate, DATE endDate, long Interval) {

   IAddresseePtr iAddr(__uuidof(Addressee));

   iAddr->EmailAddress = userUPN;
   if(iAddr->CheckName(bstr_t("LDAP://") + domainDNSName, bstr_t(), bstr_t()) == VARIANT_FALSE) {
      cerr << "Error looking up name!" << endl;
      _com_issue_error(E_FAIL);
   }

    //Get the free/busy status in Interval minute intervals from startDate to endDate
   return iAddr->GetFreeBusy(startDate, endDate, Interval, bstr_t(), bstr_t(), bstr_t(), bstr_t());

}

C#
The following example returns the free/busy status of the specified user:
// Reference to Microsoft ActiveX Data Objects 2.5 Library
// Reference to Microsoft CDO for Exchange 2000 Library
// Reference to Active DS Type Library

// Note: It is recommended that all input parameters be validated when they are
// first obtained from the user or user interface.
static string GetFreeBusyString(string strUserUPN, DateTime dtStartDate,
                                DateTime dtEndDate, int Interval)
{
   try
   {
      // Variables.
      CDO.Addressee iAddr = new CDO.Addressee();
      string freebusy;
      ActiveDs.ADSystemInfo Info = new ActiveDs.ADSystemInfo();

      iAddr.EmailAddress = strUserUPN;
      if  (!(iAddr.CheckName("LDAP://" + Info.DomainDNSName, "", "")))
         throw new System.Exception("Error occured!");

      // Get the free/busy status in Interval minute
      // intervals from dtStartDate to dtEndDate.
      freebusy = iAddr.GetFreeBusy(dtStartDate, dtEndDate,
                                   Interval, "", "", "", "");

      return freebusy;
   }
   catch (Exception err)
   {
      Console.WriteLine(err.ToString());
      return "";
   }
}
Visual Basic .NET
The following example returns the free/busy status of the specified user:
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Library
' Reference to Active DS Type Library

' Note: It is recommended that all input parameters be validated when they are
' first obtained from the user or user interface.
Function GetFreeBusyString(ByVal strUserUPN As String, ByVal dtStartDate As Date, _
                           ByVal dtEndDate As Date, ByVal Interval As Integer) As String

   Try
      ' Variables.
      Dim iAddr As New CDO.Addressee()
      Dim freebusy As String
      Dim Info As New ActiveDs.ADSystemInfo()

      iAddr.EmailAddress = strUserUPN
      If Not iAddr.CheckName("LDAP://" & Info.DomainDNSName) Then
         Throw New System.Exception("Error occured!")
      End If

     ' Get the free/busy status in Interval minute intervals
     ' from dtStartDate to dtEndDate.
     freebusy = iAddr.GetFreeBusy(dtStartDate, dtEndDate, Interval)
     GetFreeBusyString = freebusy

   Catch err As Exception
      Console.WriteLine(err.ToString())
      GetFreeBusyString = ""
   End Try
End Function
在发送会议请求之前,您可以检查与会者的日历,查看与会者何时有空。IAddressee.GetFreeBusy方法返回一个数字字符串,指示与会者在请求的时间段内的可用性。
忙/闲字符串中的每个数字表示一个时间间隔(本例中为每½小时)。空闲时间返回0,暂时返回1,忙碌返回2,外出(OOF)返回3。如果约会重叠,则返回最大数目。如果该间隔没有可用的忙/闲数据,则返回值4。
下图显示了与会者日历的一部分以及相应的忙/闲字符串。
与会者日历部分的忙/闲字符串
要获取特定时间内与会者的忙/闲状态,可以创建收件人对象并执行iadressee.GetFreeBusy方法。您还可以获取更长时间间隔的忙/闲状态,并解析字符串以查找与会者的空闲时间。
注意:您必须先调用iadressee.CheckName方法并解析收件人,然后才能使用iadressee.GetFreeBusy方法。
注意:Microsoft®Exchange Server 2003中的一个自动过程会定期更新用户的忙/闲状态。Microsoft Outlook®更新Outlook用户的忙/闲状态。协作数据对象(CDO)将Outlook忙/闲缓存与来自CDO客户端的忙/闲信息同步。将会议添加到用户日历时,忙/闲状态不会立即更新。默认情况下,Exchange存储中的系统文件夹中会保留三个月的忙/闲状态。
本主题包含微软Visual Basic®、微软VisualC++、微软Cype和VisualBasic .NET代码示例。
Visual Basic
以下示例返回指定用户的忙/闲状态:
'对Microsoft ActiveX数据对象2.5库的引用
'对Exchange 2000库的Microsoft CDO的引用
'注意:建议在输入参数时对其进行验证
'首先从用户或用户界面获取。
函数GetFreeBusyString(strUserUPN为字符串,dtStartDate为日期,dtEndDate为日期,间隔为整数)为字符串
Dim iAddr作为新的CDO收件人
像字符串一样忙
Dim信息作为新的ADSystemInfo
iAddr.EmailAddress=strUserUPN
如果不是iAddr.CheckName(“LDAP://”和Info.DomainDNSName),那么
'处理错误
如果结束
'获取从dtStartDate到dtEndDate的空闲/忙碌状态(以分钟为间隔)
freebusy=iAddr.GetFreeBusy(dtStartDate、dtEndDate、Interval)
GetFreeBusyString=freebusy
端函数
C++
以下示例返回指定用户的忙/闲状态:
/*
假设以下路径位于您的
包括路径。
%CommonProgramFiles%\system\ado
%CommonProgramFiles%\microsoft共享\cdo
*/
#导入无名称空间
#导入无名称空间
#包括
//注:建议在输入参数时对其进行验证
//首先从用户或用户界面获取。
bstr_t GetFreeBusysting(常量bstr_t&userUPN、常量bstr_t&domainDNSName、日期开始日期、日期结束日期、长间隔){
IAddresseePtr iAddr(uu uuidof(收件人));
iAddr->EmailAddress=userUPN;
if(iAddr->CheckName(bstr\u t(“LDAP:/”)+domainDNSName,bstr\u t(),bstr\u t())==VARIANT\u FALSE){

cerr谢谢你Sujay。我想这就是我想要的,虽然有点太复杂:)我会讲清楚的。@madu-请接受答案,因为它将帮助用户寻找相同问题的答案。虽然这个链接可能会回答这个问题,但最好在这里包括答案的基本部分并提供link供参考。如果链接页更改,则只有链接的答案可能无效。@shuttle87我已添加了文本。