我一直试图从VBA设置会议邀请,但我无法使用共享邮箱这样做。它的工作完美时,做了个人邮件,但我似乎不能添加共享邮箱,即使我有完全的权限。
我认为问题在于设置outAccount,它只接收我的个人电子邮件,而不是共享的
Sub send_invites(r As Long)
Dim OutApp As Outlook.Application
Dim OutMeet As Outlook.AppointmentItem
Set OutApp = Outlook.Application
Set OutMeet = OutApp.CreateItem(olAppointmentItem)
Dim OutAccount As Outlook.Account: Set OutAccount = OutApp.Session.Accounts.Item(1)
With OutMeet
.Subject = Cells(r, 1).Value
.RequiredAttendees = Cells(r, 11).Value
' .OptionalAttendees = ""
Dim sDate As Date: sDate = Cells(r, 2).Value + Cells(r, 3).Value
Dim eDate As Date: eDate = Cells(r, 4).Value + Cells(r, 5).Value
.Start = sDate
.End = eDate
.Importance = olImportanceHigh
Dim rDate As Date: rDate = Cells(r, 7).Value + Cells(r, 8).Value
Dim minBstart As Long: minBstart = DateDiff("n", sDate, eDate)
.ReminderMinutesBeforeStart = minBstart
.Categories = Cells(r, 9)
.Body = Cells(r, 10)
.MeetingStatus = olMeeting
.Location = "Microsoft Teams"
.SendUsingAccount = OutAccount
.Send
End With
Set OutApp = Nothing
Set OutMeet = Nothing
End Sub
Sub send_invites_click()
Dim rg As Range: Set rg = shData.Range("A1").CurrentRegion
Dim i As Long
For i = 2 To rg.Rows.Count
Call send_invites(i)
Next i
End Sub
字符串
2条答案
按热度按时间2fjabf4q1#
SendUsingAccount
属性需要在Outlook中配置另一个帐户。请确保您已在Outlook中配置了所需的帐户。如果您没有在Outlook中配置共享邮箱,则需要使用
SentOnBehalfOfName
属性。该属性返回或设置一个字符串,该字符串指示邮件消息的预期发件人的显示名称。请注意,在这种情况下,您必须有足够的权限代表其他人发送。xwbd5t1u2#
我明白了
因此,共享邮箱的方法是通过用户帐户识别正确的文件夹,然后才能创建会议。
SentOnBehalfOfName
似乎不是必需品。对于任何寻求解决这个问题的人,这里是完整的代码:
字符串