Solved Can Access read Outlook "User defined field values"? (1 Viewer)

TheKid

New member
Local time
Today, 08:01
Joined
Jun 4, 2021
Messages
14
Hi, I have been playing about with making an email import routine a lot more automated.

My Access code works great, extract below
Code:
Set objItems = cf.Items
   nummessages = objItems.Count
   If nummessages <> 0 Then
      DoEvents
        For i = 1 To nummessages
            Forms!frmImporter.lblwarn.Caption = "Processing item " & i & " of " & nummessages
            Forms!frmImporter.Repaint


 If TypeName(objItems(i)) = "MailItem" Then
            Set c = objItems(i)
            rstmessages.AddNew
            rstmessages.AddNew
            rstmessages!ImportedEntryID = c.EntryID
            rstmessages!ImportedStamp = Now()
            rstmessages!ImportedSender = c.SenderEmailAddress
            rstmessages!ImportedSenderName = c.SenderName
            rstmessages!ImportedFrom = c.Sender
            rstmessages!ImportedTo = c.To
            rstmessages!ImportedSubject = c.Subject
            rstmessages!ImportedBody = c.Body
            rstmessages!ImportedBodyHtml = c.HTMLBody
            rstmessages!ImportedMessageSize = c.Size
            rstmessages!ImportedImportance = c.Importance
            rstmessages!ImportedAttachments = c.Attachments.Count
            rstmessages!Received = c.DateSent
            rstmessages!ImportedDateSent = c.SentOn
            rstmessages.Update
        
                ' now look at attachments per email message as it loop into the tblTempImportedEmailattachment table
                If c.Attachments.Count > 0 Then
                        For X = 1 To c.Attachments.Count
                            MyFileName = c.Attachments.Item(X).FileName
                            rstfiles.AddNew
                            rstfiles!ImportedEntryID = c.EntryID

I wrongly presumed I would be able to add all my new shiny outlook “user defined fields” to the access code. For example rstmessages!ImportedCID = c.CleintID

The access vba Intellisense doesn’t list it and I can’t find any examples on the forum

Is this possible or have I missed something?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 03:01
Joined
May 21, 2018
Messages
8,554
If it is a property of the the Outlook object model, and you add Outlook as a reference you will see any Outlook object properties. You said user defined fields. How did you add ClientID as a field to the ObjetItem object? Any user defined property will never come up in intellisense since it is not really added to the object model it is added normally to another "properties" collection.
Try something like
rstmessages!ImportedCID = c.UserProperties("ClientID").value
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:01
Joined
May 7, 2009
Messages
19,247
maybe you mean EntryID (unique string).
 

TheKid

New member
Local time
Today, 08:01
Joined
Jun 4, 2021
Messages
14
If it is a property of the the Outlook object model, and you add Outlook as a reference you will see any Outlook object properties. You said user defined fields. How did you add ClientID as a field to the ObjetItem object?
When i was in the outlook mail form I selected "design this form" then on the Tools menu. Field chooser then New and added the ClientID
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 03:01
Joined
May 21, 2018
Messages
8,554
Any user defined property will never come up in intellisense since it is not really added to the object model it is added normally to another "properties" collection.
Try something like
rstmessages!ImportedCID = c.UserProperties("ClientID").value
 

TheKid

New member
Local time
Today, 08:01
Joined
Jun 4, 2021
Messages
14
Any user defined property will never come up in intellisense since it is not really added to the object model it is added normally to another "properties" collection.
Try something like
rstmessages!ImportedCID = c.UserProperties("ClientID").value
Great MajP that did it! Ill go and do some research on UserProperties
Thanks again (y)
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:01
Joined
May 7, 2009
Messages
19,247
there is also ItemProperties collection?
 

Users who are viewing this thread

Top Bottom