Hopner
11-11-2016, 05:46 AM
Hi guys,
After the huge success from yesterdays help, i would really like your help for a new problem!
I have the following script:
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim mynamespace As Outlook.NameSpace
Dim Inbox As Outlook.MAPIFolder
Dim myrecipient As Outlook.Recipient
Dim InboxFolder As Outlook.Folder
Set mynamespace = Application.GetNamespace("MAPI")
Set myrecipient = mynamespace.CreateRecipient("m3 research - project")
Set Inbox = mynamespace.GetSharedDefaultFolder(myrecipient, olFolderInbox)
Set Items = Inbox.Items
End Sub
Private Sub Items_ItemAdd(ByVal Item As Object)
If TypeOf Item Is Outlook.MailItem Then
'*************************************
'Your code goes in here!!!
'*************************************
End If
End Sub
For detecting incoming e-mails in our shared mailbox it works perfectly! However i need it to search for any categories added to this same inbox. Or best case scenario would be for it to search for a specific category.
I have tried using this to find the categories:
Private Sub ListCategoryIDs()
Dim objCategory As Category
Dim strOutput As String
Dim mynamespace As Outlook.NameSpace
Dim Inbox As Outlook.MAPIFolder
Dim myrecipient As Outlook.Recipient
Set mynamespace = Application.GetNamespace("MAPI")
Set myrecipient = mynamespace.CreateRecipient("m3 research - project")
Set Inbox = mynamespace.GetSharedDefaultFolder(myrecipient, olFolderInbox)
If mynamespace.categories.Count > 0 Then
For Each objCategory In mynamespace.categories
strOutput = strOutput & objCategory.name & _
": " & objCategory.CategoryID & vbCrLf
Next
End If
MsgBox strOutput
However it only looks for the categories in my own inbox.
Can anybody help me with this? If any clarification is needed please ask!
After the huge success from yesterdays help, i would really like your help for a new problem!
I have the following script:
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim mynamespace As Outlook.NameSpace
Dim Inbox As Outlook.MAPIFolder
Dim myrecipient As Outlook.Recipient
Dim InboxFolder As Outlook.Folder
Set mynamespace = Application.GetNamespace("MAPI")
Set myrecipient = mynamespace.CreateRecipient("m3 research - project")
Set Inbox = mynamespace.GetSharedDefaultFolder(myrecipient, olFolderInbox)
Set Items = Inbox.Items
End Sub
Private Sub Items_ItemAdd(ByVal Item As Object)
If TypeOf Item Is Outlook.MailItem Then
'*************************************
'Your code goes in here!!!
'*************************************
End If
End Sub
For detecting incoming e-mails in our shared mailbox it works perfectly! However i need it to search for any categories added to this same inbox. Or best case scenario would be for it to search for a specific category.
I have tried using this to find the categories:
Private Sub ListCategoryIDs()
Dim objCategory As Category
Dim strOutput As String
Dim mynamespace As Outlook.NameSpace
Dim Inbox As Outlook.MAPIFolder
Dim myrecipient As Outlook.Recipient
Set mynamespace = Application.GetNamespace("MAPI")
Set myrecipient = mynamespace.CreateRecipient("m3 research - project")
Set Inbox = mynamespace.GetSharedDefaultFolder(myrecipient, olFolderInbox)
If mynamespace.categories.Count > 0 Then
For Each objCategory In mynamespace.categories
strOutput = strOutput & objCategory.name & _
": " & objCategory.CategoryID & vbCrLf
Next
End If
MsgBox strOutput
However it only looks for the categories in my own inbox.
Can anybody help me with this? If any clarification is needed please ask!