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
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 = Item
If 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
Else
Debug.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").Value
End If
Next
End Sub
- v-aatheeque1 year agoCommunity Support
Hi Amazon777 ,
Glad that your query got resolved and If our response addressed by the community member for your query, please mark it as Accept Answer and click Yes if you found it helpful.Should you have any further questions, feel free to reach out.
Thank you for being a valued member of the Microsoft Fabric Community Forum!