Excel 如何向一个收件人发送会议请求';s忙碌状态不在办公室,一个显示为空闲
我想向AssociateMail和BranchManager发送一份会议邀请电子邮件,其中同事的会议显示为“OlAutofoffice”,但分行经理显示为“olFree” 当我希望收件人使用Busy Status属性时,该属性似乎位于约会上 我知道Outlook会分别保存这两个值,因为一个人可以在接受后进入并更改该值 这是我到目前为止所拥有的Excel 如何向一个收件人发送会议请求';s忙碌状态不在办公室,一个显示为空闲,excel,vba,outlook,Excel,Vba,Outlook,我想向AssociateMail和BranchManager发送一份会议邀请电子邮件,其中同事的会议显示为“OlAutofoffice”,但分行经理显示为“olFree” 当我希望收件人使用Busy Status属性时,该属性似乎位于约会上 我知道Outlook会分别保存这两个值,因为一个人可以在接受后进入并更改该值 这是我到目前为止所拥有的 Function SendMeetingRequest(subject As String, location As String, startDateT
Function SendMeetingRequest(subject As String, location As String, startDateTime As Date, durationMinutes As Integer, associateEmail As String, branchManagerEmail As String, allDayEvent As Boolean) As Boolean
On Error GoTo ErrorHandler
SendMeetingRequest = True
Dim myOutlook As Object
Dim myApt As AppointmentItem
' Create the Outlook session
Set myOutlook = CreateObject("Outlook.Application")
' Create the AppointmentItem
Set myApt = myOutlook.CreateItem(olAppointmentItem) ' Set the appointment properties
Dim r As recipient
Set r = myApt.recipients.Add(associateEmail)
r.Type = OlMeetingRecipientType.olRequired
Set r = myApt.recipients.Add(branchManagerEmail)
r.Type = OlMeetingRecipientType.olOptional
With myApt
.subject = subject
.location = location
.Start = startDateTime
.duration = durationMinutes
.MeetingStatus = olMeeting
.allDayEvent = allDayEvent
.BusyStatus = olFree
.ReminderSet = False
.Save
.send
End With
Exit Function
ErrorHandler:
MsgBox Err & ": " & Error(Err)
SendMeetingRequest = False
End Function
您好,请尝试设置对Outlook库的引用和此代码 您可以通过查看以下内容来检查如何添加对库的引用。我在您的代码中看到,您正在使用outlook常量,我不确定您是否正在使用早期绑定,因此代码无法识别常量的正确值 如果你仔细观察,你会发现变量“olBusy”的值为2,“olFree”的值为0;也许代码没有理解变量,并给它一个默认的int值0(自由状态) 我希望这有帮助
On Error GoTo ErrorHandler
SendMeetingRequest = True
' Create the Outlook session
Set myOutlook = New Outlook.Application
Set myApt = myOutlook.CreateItem(olAppointmentItem) ' Set the appointment properties
Set r = myApt.Recipients.Add(associateEmail)
r.Type = OlMeetingRecipientType.olRequired
Set r = myApt.Recipients.Add(branchManagerEmail)
r.Type = OlMeetingRecipientType.olOptional
With myApt
.subject = subject
.location = location
.Start = startDateTime
.Duration = durationMinutes
.MeetingStatus = olMeeting
.allDayEvent = allDayEvent
.BusyStatus = olBusy
.ReminderSet = False
.Save
.send
End With
Exit_Handler:
Exit Function
ErrorHandler:
MsgBox Err & ": " & Error(Err)
SendMeetingRequest = False
Resume Exit_Handler
End Function
我会感到惊讶,如果这可以在一个非琐碎的方式发送时,像这样
.BusyStatus
是每个人都可以单独覆盖的东西,但我怀疑它在发送时是否可以设置为可变的。你能想出一种非常简单的方法吗?我会研究一下。为方便起见,我建议对outlook应用程序实例使用早期绑定。只需引用Outlook库并将Dim myApt用作新Outlook。我想值得尝试将收件人引用为实际联系人或联系人项目。它将是一个对象,而不仅仅是一个电子邮件地址。您可以像这样访问myOutlook.Session.GetDefaultFolder(olFolderContacts.Items)。顺便说一句,在我18个月前发布的之前的评论中,我是想让myOutlook变暗,而不是myApt。我不再做那个项目了,所以没有:)
On Error GoTo ErrorHandler
SendMeetingRequest = True
' Create the Outlook session
Set myOutlook = New Outlook.Application
Set myApt = myOutlook.CreateItem(olAppointmentItem) ' Set the appointment properties
Set r = myApt.Recipients.Add(associateEmail)
r.Type = OlMeetingRecipientType.olRequired
Set r = myApt.Recipients.Add(branchManagerEmail)
r.Type = OlMeetingRecipientType.olOptional
With myApt
.subject = subject
.location = location
.Start = startDateTime
.Duration = durationMinutes
.MeetingStatus = olMeeting
.allDayEvent = allDayEvent
.BusyStatus = olBusy
.ReminderSet = False
.Save
.send
End With
Exit_Handler:
Exit Function
ErrorHandler:
MsgBox Err & ": " & Error(Err)
SendMeetingRequest = False
Resume Exit_Handler
End Function