我正在使用Access VBA在Outlook中创建约会,但无法将约会发送给与会者。我可以保存约会,当我打开约会时,与会者列表会显示在“收件人:”字段中,但是会出现一条消息,提示“您尚未发送此会议邀请”。我可以在此处点击“发送”按钮,邀请将发送给预定的收件人。如果我只显示它,也是如此。我尝试过在发送之前和之后是否包含保存的情况。 我按照建议编辑了代码,并删除了On Error Resume Next。再次运行代码后,没有任何错误显示。
这是我的代码:
Dim objApp As Object
Dim objNS As Object
Dim objFolder As Object
Dim objMsg As Object
Dim objRecip As Object
Dim objAppt As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objMsg = objApp.CreateItem(olMailItem)
'The Calendar can either be set with the name of the calendar or the Folder ID
If Left(strName, 3) = "ID:" Then
'Strip out the ID: identifier and leave just the ID
strName = Mid(strName, 5, Len(strName))
Set objFolder = objNS.GetFolderFromID(strName)
Else
Set objRecip = objMsg.Recipients.Add(strName)
objRecip.Resolve
If objRecip.Resolved Then
Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar)
Else
MsgBox "Could not find " & Chr(34) & strName & Chr(34), , "User not found"
bError = True
GoTo Exit_Handler
End If
End If
If Not objFolder Is Nothing Then
Set objAppt = objFolder.Items.Add
If Not objAppt Is Nothing Then
With objAppt
.Subject = strSubject
.Start = dtStartDate
.End = dtEndDate
.Body = strBody
.Location = strLocation
.Categories = strColorCategory
.Recipients.Add strAttendees
'Use Display for debugging
'.Display
'.Save
.Send
bError = False
End With
End If
End If