Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
扩展我的Outlook VBA代码以使用忙/闲和日程安排应用程序_Vba_Outlook - Fatal编程技术网

扩展我的Outlook VBA代码以使用忙/闲和日程安排应用程序

扩展我的Outlook VBA代码以使用忙/闲和日程安排应用程序,vba,outlook,Vba,Outlook,我有时会去国际旅行,当我去的时候,我必须会见5到10个内部同事。到目前为止,我所做的是使用以下代码发送介绍,看看他们什么时候可以自由见面。我将他们的名字和姓氏输入Excel,以及我是否见过他们 Sub CreateInvite(lngDuration As Long, strInviteBody As String, strLocation As String, strSubject As String, strRec As String) Dim olApp As Outlook.Applic

我有时会去国际旅行,当我去的时候,我必须会见5到10个内部同事。到目前为止,我所做的是使用以下代码发送介绍,看看他们什么时候可以自由见面。我将他们的名字和姓氏输入Excel,以及我是否见过他们

Sub CreateInvite(lngDuration As Long, strInviteBody As String, strLocation As String, strSubject As String, strRec As String)
Dim olApp As Outlook.Application
Dim olMeetingInvite As AppointmentItem
Set olApp = CreateObject("outlook.application")
Set olMeetingInvite = olApp.CreateItem(olAppointmentItem)
With olMeetingInvite
.Body = strInviteBody
.Display
.Recipients.Add strRec
.Recipients.ResolveAll
.Subject = strSubject
.Location = strLocation
.Duration = lngDuration
End With
End Sub
Sub RunInviteCreator()
Dim strRec As String
Dim strRecFirstName As String
Dim strLoc As String
Dim xlApp As Excel.Application
Set xlApp = CreateObject("excel.application")
Dim xlWS As Excel.Workbook
Set xlWS = xlApp.Workbooks.Open("C:\Invitees.xls")
Dim xlSheet As Excel.Worksheet
Set xlSheet = xlWS.ActiveSheet
Dim strSubject As String
Dim strLocation As String
Dim i As Integer
Dim iMeetingLength As Integer
Dim strHour As String
Dim strMeetingLength As String
Dim strInviteBody1 As String
Dim strInviteBody2 As String
Dim strInviteBody As String
Dim strKnown As String

For i = 2 To 21
strRecFirstName = xlSheet.Cells(i, 1)
strRec = xlSheet.Cells(i, 3)
strSubject = xlSheet.Cells(i, 6)
strLocation = xlSheet.Cells(i, 8) & "/" & xlSheet.Cells(i, 9)
iMeetingLength = xlSheet.Cells(i, 7)
If iMeetingLength > 60 Then strHour = "hours" Else strHour = "hour"
strMeetingLength = CStr(iMeetingLength / 60)
strInviteBody1 = "Dear " & strRecFirstName & "," & vbCrLf

strKnown = "Allow me to introduce myself. I am Mahin from HQ in Boise." & vbCrLf & vbCrLf

strInviteBody2 = _
"I will be in " & area & "from May 17 to May 23 and would really like to meet with you, learn about your business and see how we can cooperate to drive initiatives in FY10." & vbCrLf & vbCrLf & _
"I’ve checked your calendar and this looks like a good time. If not, however, please feel free to propose a new time. The best time would be Friday, which I am leaving open to accommodate calendar reschedules. Also, I have booked this for " & strMeetingLength & " " & strHour & ". If you feel the meeting needs to be longer or shorter, please let me know." & vbCrLf & vbCrLf & _
"I really look forward to meeting you and working with you." & vbCrLf & vbCrLf & _
"Best Regards," & vbCrLf & vbCrLf & _
"Mahin" 

If xlSheet.Cells(i, 10) = "Yes" Then
strInviteBody = strInviteBody1 & strInviteBody2
Else
strInviteBody = strInviteBody1 & strKnown & strInviteBody2
End If

CreateInvite CLng(iMeetingLength), strInviteBody, strLocation, strSubject, strRec
Next i

End Sub

我想做的是首先检查所有这些人的Exchange忙/闲状态,然后让我的程序向他们的日历发送邀请,并在上面的邮件中引用。有人能给我一些关于如何在Outlook OM中执行此操作的建议吗?谢谢

有关忙/闲信息,请查看-您需要对结果进行一些解析

对于日历邀请,您只需创建一个olAppointmentItem类型的新项目,例如: 设置myItem=myOlApp.CreateItem(olAppointmentItem)
示例。

您还需要设置AppointmentItem.MeetingStatus=olMeeting,以便将其视为会议(并发送邀请)。