Pog1
04-19-2016, 07:00 AM
Hi,
New to this VBA in Outlook (but can program in Excel). Have written a macro which works processing new messages to the default inbox using
Set Items = objNS.GetDefaultFolder(olFolderInbox).Items This macro monitors MY PERSONAL work inbox, abc. I am subscribed to a second, COMMUNAL inbox (which I will soon be getting admin permission for), def. How do I point the code to THIS inbox, please? Full code below:
Thanks so much for your interest. Incidentally, what is the technical term for these different accounts I have access to in Outlook, please?
Private WithEvents Items As Outlook.ItemsPrivate Sub Application_Startup()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace("MAPI")
' default local Inbox
Set Items = objNS.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub Items_ItemAdd(ByVal item As Object)
On Error GoTo ErrorHandler
Dim Msg As Outlook.MailItem
If TypeName(item) = "MailItem" Then
Set Msg = item
Call Send_ReplyII(Msg)
End If
ProgramExit:
Exit Sub
ErrorHandler:
MsgBox Err.Number & " - " & Err.Description
Resume ProgramExit
End Sub
New to this VBA in Outlook (but can program in Excel). Have written a macro which works processing new messages to the default inbox using
Set Items = objNS.GetDefaultFolder(olFolderInbox).Items This macro monitors MY PERSONAL work inbox, abc. I am subscribed to a second, COMMUNAL inbox (which I will soon be getting admin permission for), def. How do I point the code to THIS inbox, please? Full code below:
Thanks so much for your interest. Incidentally, what is the technical term for these different accounts I have access to in Outlook, please?
Private WithEvents Items As Outlook.ItemsPrivate Sub Application_Startup()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace("MAPI")
' default local Inbox
Set Items = objNS.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub Items_ItemAdd(ByVal item As Object)
On Error GoTo ErrorHandler
Dim Msg As Outlook.MailItem
If TypeName(item) = "MailItem" Then
Set Msg = item
Call Send_ReplyII(Msg)
End If
ProgramExit:
Exit Sub
ErrorHandler:
MsgBox Err.Number & " - " & Err.Description
Resume ProgramExit
End Sub