Forum Discussion
User Defined Fields In Outlook are not displaying in Power Query
- 1 year ago
I decided not to use Power Query.
Thank you for all your help.
This is a solution to pull out from Outlook User Defined fields including the subect and other fields within the email from and a folder in the Inbox named "test folder".
Team - I worked with a colleague this morning and he gave me a solution using VBA in Outlook.
I loaded this module into Outlook VBA.
Sub Test()
'On Error Resume Next
Dim objNS As Outlook.NameSpace: Set objNS = GetNamespace("MAPI")Dim olFolder As Outlook.MAPIFolder
'Set olFolder = objNS.GetDefaultFolder(olFolderInbox)
Dim Item As Object
Set olFolder = Application.Session.GetDefaultFolder(olFolderInbox).Folders("test folder")
For Each Item In olFolder.Items
Dim oMail As Outlook.MailItem: Set oMail = ItemIf oMail.UserProperties.Find("Action") Is Nothing Or _
oMail.UserProperties.Find("Risk") Is Nothing Or _
oMail.UserProperties.Find("Incident") Is Nothing Then
Debug.Print oMail.Subject & " | " & _
oMail.SenderName & " | " & _
oMail.ReceivedByName & " | " & _
oMail.CC & " | " & _
oMail.ReceivedTime
ElseDebug.Print oMail.Subject & " | " & _
oMail.SenderName & " | " & _
oMail.ReceivedByName & " | " & _
oMail.CC & " | " & _
oMail.ReceivedTime & " | " & _
oMail.UserProperties.Find("Action").Value & " | " & _
oMail.UserProperties.Find("Risk").Value & " | " & _
oMail.UserProperties.Find("Incident").ValueEnd If
Next
End Sub
thank you - I am a novice so I will explore these solutions.
I appreciate the time you took to answer me.
Thanks,
Josh