将多个与会者添加到在 MS Project 中创建的 Outlook 会议邀请

问题描述 投票:0回答:1

我对 VBA 很陌生,但是感谢您和 google,我成功地将我在 MS Project 中创建的任务作为会议放在分配资源的 Outlook 日历中。

唯一的问题是该任务只放入 1 个人的日历中(仅第一个),即使我为一个任务分配了多个资源。

有人可以帮我将多个资源添加到 Outlook 会议邀请中吗?以下是我迄今为止一直在使用的脚本。

预先感谢您的帮助!

Option Explicit

Public myOLApp As Outlook.Application

Sub Export_Selection_To_OL_Appointments()
        Dim myTask As Task
        Dim myItem As Outlook.AppointmentItem
        Dim myRequiredAttendee As Outlook.Recipient 'Vas as Set Outlook Recipient
        Dim myPResEmail As String 'Var as email Address-String

 On Error Resume Next  'if error found, jump to next
'Starts Microsoft Outlook (if it's not already running) and opens the default Inbox folder
Set myOLApp = CreateObject("Outlook.Application")

 For Each myTask In ActiveSelection.Tasks 'Loop through the tasks
Set myItem = myOLApp.CreateItem(olAppointmentItem) 'Create an appointment
With myItem                    'For each appointment do something
.MeetingStatus = olMeeting     'Set the meeting status to meeting
.Start = myTask.Start          'Set the start and finish
.End = myTask.Finish
.Subject = myTask.Name & " (MS Project Task)"
.Location = myTask.Text3
.Categories = myTask.UniqueID
.Body = myTask.Notes
.BusyStatus = olFree

                'Add a required attendee
                myPResEmail = myTask.Resources(1).EMailAddress   'Resources(1).EMailAddress
                Set myRequiredAttendee = .Recipients.Add(myPResEmail)
                myRequiredAttendee.Type = olRequired

                'Set a reminder
                .ReminderSet = True
                .ReminderOverrideDefault = True
                .ReminderMinutesBeforeStart = myTask.Number1
                
                 'Make this appointment unique for later reference
                .Categories = myTask.Guid
                '.Class = myTask.Guid

            '.Save
             'Send this meeting invite
            .Send

 End With
Next myTask

End Sub

谢谢

ms-project
1个回答
0
投票

要将所有已分配的资源添加到会议邀请,请循环访问任务的分配:

'Add required attendees
Dim asn As Assignment
For Each asn in myTask.Assignments
    Set myRequiredAttendee = .Recipients.Add(asn.Resource.EMailAddress)
    myRequiredAttendee.Type = olRequired
Next asn
© www.soinside.com 2019 - 2024. All rights reserved.