Forum Discussion

Amazon777's avatar
Amazon777
Regular Visitor
1 year ago
Solved

User Defined Fields In Outlook are not displaying in Power Query

I have successfully linked Outlook to Power Query. I can bring in the Subject, Sender.  I cannot seem to find the User Defined Fields as column choices within Power Query.        Thanks, Josh
  • Amazon777's avatar
    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 = 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