我正在编写一个脚本,通过阅读MS Excel工作表来自动化Outlook中的OOO。
21-Oct-2016
和24-Oct-2016
,并且此脚本在20-Oct-2016
上运行,则应该能够设置OOO起始21-Oct-2016
1}}自动24-Oct-2016
(无需打开MS Outlook)这是正在进行的代码:
Sub ReadDataAndSetOOO()
Dim objExcel,ObjWorkbook,objsheet
intRow = 2
Dim startDateValue, endDateValue
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\input.xlsx")
set objsheet = objExcel.ActiveWorkbook.Worksheets(1)
DateToday = FormatDateTime(Date, 1)
DateTomorrow = formatDate(FormatDateTime(DateAdd("d", 1, DateToday), 1))
Wscript.Echo DateTomorrow
Do Until objExcel.Cells(intRow,1).Value = ""
startDateValue = formatDate(FormatDateTime(objsheet.Cells(intRow,1).value,1))
endDateValue = formatDate(FormatDateTime(objsheet.Cells(intRow,2).value))
Wscript.Echo "Start date=" & startDateValue
Wscript.Echo "End date=" & endDateValue
If DateTomorrow = startDateValue Then
'Following line to be replaced by the code to set OOO between start and end date
Wscript.Echo "I am on leave from " & startDateValue & " to " & endDateValue
End If
intRow = intRow + 1
Loop
objExcel.ActiveWorkbook.Close
objExcel.Workbooks.Close
objExcel.Application.Quit
End Sub
Function formatDate(myDate)
d = parse(Day(myDate))
m = parse(Month(myDate))
y = Year(myDate)
formatDate= d & "-" & m & "-" & y
End Function
Function parse(num)
If(Len(num)=1) Then
parse="0"&num
Else
parse=num
End If
End Function
ReadDataAndSetOOO
我提到this link和其他一些链接,但在任何地方,OOO都是立即设置的,而不是所需的开始和结束日期。
任何指针都表示赞赏。
答案 0 :(得分:1)
OOF时间范围只能通过EWS设置,即使用UserOofSettings动词。无法使用Outlook对象模型或扩展MAPI进行设置。
如果使用Redemption是一个选项,它会公开RDOOutOfOfficeAssistant对象。由于它执行EWS呼叫,因此需要邮箱用户的凭据。
#11:2, #61:1, #61:2, #61:3, #62:1