Is there an ID field you can use to pair a reply to the sent email?

Status
Not open for further replies.
Outlook version
Outlook 2016 64 bit
Email Account
IMAP
Hi all,

Is there a field within an Outlook mailItem which allows you to store an ID number e.g. 123456 which you can read from their reply email?
I am trying to insert a contactId somewhere in the email which I can read when the person replies and use to make updates to an Access database. I would rather not have to show the contactId in the body of the email. I tried using the 'mileage' field but it came back empty in the reply.

I have tried to capture conversationID from the last sent message in the sent folder and then pair it with the conversationID of the reply email but they don't match up.

The code I used to get the conversationID of the last sent message in the sent folder is:
Dim ns As NameSpace
Dim f As Folder
Dim items As items


Dim mailSent As MailItem

Set ns = Application.Session
Set f = ns.GetDefaultFolder(olFolderSentMail)
Set items = f.items

items.Sort "SentOn", False
Set mailSent = items.Item(items.Count)
Debug.Print mailSent.Subject
Debug.Print "last mail sent: " & mailSent.ConversationID

The code I used to get the conversationID from the reply email is:
Dim oApp As Outlook.Application
Set oApp = GetObject(, "Outlook.Application")
Dim oMail As Outlook.MailItem
Set oMail = oApp.ActiveExplorer.Selection.Item(1)

Debug.Print oMail.ConversationID


Thanks!
 
Do you want to add a contactid field to the message that matches a contact? If you want to use a unique code that is in the message, the entryid would work.

You can't replace a field that already exists but can add a custom field.
 
Hi Diane, thanks for your reply.
I tried the Entry ID but that didn't match between the sent and reply emails unfortunately.
I tried your custom field idea but have come up against an error.

I have two buttons in the Outlook ribbon: the first one sends the email with this code:
Dim oApp As Outlook.Application
Dim oMail As Outlook.MailItem
Dim UserProp As Outlook.UserDefinedProperty
Set oApp = GetObject(, "Outlook.Application")

Set oMail = oApp.CreateItem(olMailItem)
oMail.Display
oMail.To = "franc@workingdata.co.uk"
oMail.Mileage = 1234567890
oMail.Subject = "Unsubscribe"
oMail.UserProperties.Add("contactId", olNumber) = 1234567890
oMail.Save
oMail.Send
I received the email from Outlook to another email address for which I use Thunderbird. I reply with a few words and send the email back. I then try to read the 'contactId' field from the reply email using your code (slightly amended):
Dim UserProp As Outlook.UserDefinedProperty
Dim obj As Object
Dim contactId As Long

Set obj = Application.ActiveExplorer.Selection.Item(1)

On Error Resume Next
Set UserProp = obj.UserProperties.Find("contactId")
If Not UserProp Is Nothing Then
contactId = obj.UserProperties("contactId").Value
MsgBox strCurrent
Else
MsgBox "Field not found"
End If

Set obj = Nothing

End Sub
This brings up the messagebox 'Field not found'. I'm sure I've spelt the custom field the same way in both subs. Any ideas?
 
Ah yeah, the custom field is not sent with the message.

The thread index in the header should work - as long as the sending server doesn't strip it out.

Original from client:
Thread-Index: AdbFGPx6nS1EldD1QR+/viR5PfRk7QCIIw9A

My message to him does not have a thread id (or a header)
But the reply back has this - using just the first 10 or 20 characters should work.
Thread-Index: AdbFGPx6nS1EldD1QR+/viR5PfRk7QCIIw9AAAimK3AAAdIzAA==
 
Hi Diane, I couldn't find 'Thread-Index' as an option for an olMailItem.

When I tried Conversation Index there wasn't the similarity that you showed in your example. How do email clients know how to put together emails into conversation threads? Is that what I'm missing?
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P Can't add custom field to custom Outlook form, it always adds to the Folder instead Outlook VBA and Custom Forms 2
H Copying email address(es) in body of email and pasting in To field Outlook VBA and Custom Forms 1
D Outlook VBA forward the selected email to the original sender’s email ID (including the email used in TO, CC Field) from the email chain Outlook VBA and Custom Forms 2
D Outlook 365 Custom forms field limit? Outlook VBA and Custom Forms 4
Witzker Set Cursor & Focus from any field to the body of a user Contact form in OL 2019 Outlook VBA and Custom Forms 1
S Combination Field (Date Format) Outlook VBA and Custom Forms 0
Witzker Add a text line at the end of the note field in all selected Contacts Outlook VBA and Custom Forms 7
M copy field value to custom field Outlook VBA and Custom Forms 0
J images on note field display fraction of size Using Outlook 5
C Automatically Insert Recipient Name from To Field Outlook VBA and Custom Forms 4
J How to create a drop down user defined field that will appear on an inbox view Outlook VBA and Custom Forms 8
C Move or copy from field to field Outlook VBA and Custom Forms 0
O Filter-Query Builder-Description - what field name to use? Using Outlook 4
J VBA Cannot programmatically input or change Value for User Defined field Using Outlook 1
justicefriends How to set a flag to follow up using VBA - for addressee in TO field Outlook VBA and Custom Forms 11
N Contact Form Notes Field Touch vs Mouse Using Outlook 0
S CONTACT FIELD PRINT ORDER Outlook VBA and Custom Forms 1
V Checking for empty field Outlook VBA and Custom Forms 2
V Update new custom field Outlook VBA and Custom Forms 5
HappyDaddy007 "Size" on field chooser/column displaying incorrect value Using Outlook 3
H Information from user defined field into Excel Outlook VBA and Custom Forms 7
I Outlook 2003 shows html code when To: field is empty Using Outlook 7
Terry Sullivan Sender's Name Doesn't Appear in the From Field on Outlook 365/IMAP Using Outlook 2
D Outlook Contacts Notes Field Photos to Smartphone Using Outlook 0
S Custom Field Cannot Be Displayed In Views Outlook VBA and Custom Forms 2
Terry Sullivan Sender Field Displays My E-Mail Address, Not My Name Using Outlook 1
S Create a clickable custom column field Outlook VBA and Custom Forms 0
B User defined field for messages with 'me' in the [To], [Cc] line Using Outlook 0
V Limiting text length in free text field Outlook VBA and Custom Forms 2
C Outlook 2016 Conditional Format for User Defined Field Using Outlook 1
C Copy Outlook contact field value to another field Outlook VBA and Custom Forms 1
A new labeled phone field Using Outlook 4
V Making a Date field mandatory in outlook form Outlook VBA and Custom Forms 2
B Outlook Business Contact Manager with SQL to Excel, User Defined Fields in BCM don't sync in SQL. Can I use VBA code to copy 1 field to another? BCM (Business Contact Manager) 0
BretAB Is it possible to add a lookup field to a Message form? Outlook VBA and Custom Forms 4
N Exporting IM Address field Using Outlook 2
M Using field names to capture a data element Using Outlook 0
J How to restore field no longer visible in field chooser? Using Outlook 1
S Custom Form, copy user field data to message body Outlook VBA and Custom Forms 12
R What's supposed to appear when just clicking into the search field? Using Outlook 7
A Missing context menu on Location field Using Outlook 2
G Entered data in custom field goes in card and does not stay in list view Outlook VBA and Custom Forms 1
C Changed By field not displaying individual user's name in O365 Shared Mailbox Using Outlook 9
M Making Subject field writable (disable Read Only) Outlook VBA and Custom Forms 2
C Import Outlook 2016 contacts into to: field Using Outlook 1
T Source of Outlook 2016 Address field dropdown "Other Suggestions" Using Outlook 3
S BCM Compulsory field, New opportunity Outlook VBA and Custom Forms 0
M Sudden change in From field - now very short Using Outlook 4
L Automatically Insert Recipient Name from To Field Outlook VBA and Custom Forms 33
J Assess content of User Defined Field in Rule Using Outlook 3

Similar threads

Back
Top