1

Я пытаюсь получить доступ к общему почтовому ящику, но постоянно получаю сообщение об ошибке при перезагрузке Outlook.


Private WithEvents Items As Outlook.Items

Private Sub Application_Startup() Dim olApp As Outlook.Application Dim myRecipient As Outlook.Recipient Dim myNamespace As Outlook.NameSpace

Set olApp = Outlook.Application Set myRecipient = myNamespace.CreateRecipient("accounts payable") Set Items = GetNS(olApp).GetSharedDefaultFolder(myRecipient, olFolderInbox).Folders("printed invoices")

End Sub

Private Sub Items_ItemAdd(ByVal item As Object)

On Error GoTo ErrorHandler

MsgBox "You moved an item into the 'Stuff' folder."

Dim MsgReply As Outlook.MailItem Set MsgReply = item.Reply With MsgReply .Subject = "Re " & item.Subject .HTMLBody = "Hello" & MsgReply.HTMLBody .Send End With Set MsgReply = Nothing

ProgramExit: Exit Sub ErrorHandler: MsgBox Err.Number & " - " & Err.Description Resume ProgramExit End Sub

Function GetNS(ByRef app As Outlook.Application) As Outlook.NameSpace Set GetNS = app.GetNamespace("MAPI") End Function

0