从非默认帐户答复会议请求



回复发送到Outlook 365桌面中非默认帐户的会议邀请时,通常会从默认帐户进行响应。以下代码修复了该问题,但最近已停止正常工作。

我的回答过去常说;对NONdefaultrecipientemail@gmail.com将出席"发件人:nondefaultrecipientemail@gmail.com.">

现在它说,";对Defaultemail@gmail.com将出席"发件人:nondefaultrecipientemail@gmail.com代表Defaultemail@gmail.com.">

关于为什么这种方法不再有效以及如何修复它,有什么想法吗?

谢谢!

Sub MeetingResponse(myAction As String) 
'If a meeting request is sent to the non-default email address, replies, etc., will normally come from the default email.
'This macro changes the send from email address to the correct one.
Dim myNameSpace As Outlook.NameSpace
Dim myAppt As Outlook.AppointmentItem
Dim oMtgResponse, oReplyForward, oMtgRequest As Outlook.MeetingItem

Dim oAccount As Outlook.Account
Dim SendAcct As Variant
Dim SendEmailAddr As String
Dim FolderParent As String

Set myNameSpace = Application.GetNamespace("MAPI")
'Determine which account invite was sent to.
FolderParent = Application.ActiveExplorer.CurrentFolder.Parent
For Each oAccount In Application.Session.Accounts
If oAccount.DeliveryStore.GetDefaultFolder(olFolderInbox).Parent = FolderParent Then
SendAcct = oAccount.DisplayName
Exit For
End If
Next

Set oMtgRequest = GetCurrentItem()

If TypeName(oMtgRequest) <> "Nothing" Then

Set myAppt = oMtgRequest.GetAssociatedAppointment(True)

'Set send from account
For Each oAccount In Application.Session.Accounts
If oAccount = SendAcct Then
Select Case UCase(myAction)

Case "ACCEPT"
Set oMtgResponse = myAppt.Respond(olResponseAccepted, True)
oMtgResponse.SendUsingAccount = oAccount
oMtgResponse.Display
oMtgRequest.Delete

Case "DECLINE"
Set oMtgResponse = myAppt.Respond(olResponseDeclined, True)
oMtgResponse.SendUsingAccount = oAccount
oMtgResponse.Display
oMtgRequest.Delete

'Original inviter may be notified this was forwarded.
Case "FORWARD"
Set oReplyForward = oMtgRequest.Forward
oReplyForward.SendUsingAccount = oAccount
oReplyForward.Display

'Original inviter will not be notified this was forwarded.
'Creates new appointment based on original one.
Case "FORWARDSILENT", "FORWARD SILENT"
Dim oAppt As AppointmentItem
Set oAppt = Application.CreateItem(olAppointmentItem)

With oAppt
.MeetingStatus = olMeeting
.Subject = "Accepted: " & myAppt.Subject
.Start = myAppt.Start
.Duration = myAppt.Duration
.Location = myAppt.Location
.Body = myAppt.Body
.Display
.SendUsingAccount = oAccount
End With

Case "REPLY"
Set oReplyForward = oMtgRequest.reply
oReplyForward.SendUsingAccount = oAccount
oReplyForward.Display

Case "FORWARDASATTACHMENT", "FORWARD AS ATTACHMENT"

Case Else
MsgBox "Could not process!  Incorrect action provided.", vbCritical + vbOKOnly

End Select


Exit For
End If
Next

End If
End Sub 'MeetingResponse

会议项目。SendUsingAccount属性允许设置一个Account对象,该对象表示用于发送MeetingItem的帐户。但在您的代码中,您试图将属性设置为一个字符串,该字符串包含所选帐户的显示名称。

在代码中声明Account类的实例,并按以下方式初始化它:

FolderParent = Application.ActiveExplorer.CurrentFolder.Parent
For Each oAccount In Application.Session.Accounts
If oAccount.DeliveryStore.GetDefaultFolder(olFolderInbox).Parent = FolderParent Then
Set SendAcct = oAccount
Exit For
End If
Next

然后您可以正确设置MeetingItem.SendUsingAccount属性:

oMtgResponse.SendUsingAccount = oAccount

相关内容

  • 没有找到相关文章

最新更新