Restricting session mail with ConversationID

Not open for further replies.

Jim H.

New Member
Outlook version
Outlook 2010 32 bit
Email Account
I have an Access database designed to track Work Orders for maintenance to properties. When an owner emails a request for maintenance, a work order is started. What the users of the database would like to do is track the email conversation associated with the Work Order.

In Access, I've linked to the InBox of the maintenance account in Outlook. In Microsoft's great wisdom, I'm not given access to the EntryID or ConversationID of a message, but with some hocus-pocus, I've managed to get the ConversationID. But I can't get Outlook to open a separate session that shows only the messages associated with that ID.

Here's the code I'm using:

strEmailAccount = DLookup("EmailAccount", "tblAdmin")

'Open Outlook session with emails restricted to the ConversationID
Set objOL = CreateObject("Outlook.Application") 'Create a new instance
strFilter = "[ConversationID] = '" & strConversationID & "'"
For Each objAccount In objOL.Session.Accounts
If objAccount = strEmailAccount Then
Set objStore = objAccount.DeliveryStore
Set objInbox = objStore.GetDefaultFolder(olFolderInbox)
Set objEmails = objInbox.Items.Restrict(strFilter)
End If

What am I doing wrong, or is it even possible to use the Restrict method with ConversationID (can't find any documentation that says I can't).

Many thanks.
The Restrict function returns the items matching the filter, it doesn´t change what is displayed in the folder. You´d have to use an MSForm with a listview control on it to display the items yourself.
Thank you, Michael. This is my first foray into trying to control Outlook from MS Access (other than simply sending an email from within Access--I've done that many times). I failed to say in my first question that I'm getting an error message when the code reaches the .Restrict line (Set objEmails = objInbox.Items.Restrict(strFilter).

Here's the message: Error - 2147352567 (Condition is not valid.)

This led me to believe that I couldn't restrict on the ConversationID, but I couldn't find any documentation that said I couldn't. Can you tell me definitively whether I can use the Restrict method with this email property? Is my line of code valid?

When you say I have to use an "MSForm with a listview control," I assume you mean an Access form with that control on it. What I'd really like to do is let Outlook handle all the email functions. There could be several replies sent back and forth between the owner and the maintenance folks, so I'd like to display the conversation in an Outlook session--but only the emails associated with that conversation. Do I have to create my own Outlook form to do this?

On someone else's suggestion, I bought Sue Mosher's book Microsoft Outlook 2007 Programming. So far, I've not found the answer, but I haven't read the whole book yet, either. Someone has also suggested I use Redemption to get this done, so I downloaded and installed that, but haven't been able to make it work yet.

Still scratching my head, so if you could provide the code or point me to a website or book where I might find it, I'd be grateful.

Again, many thanks for your help.
So you have two issues, 1) get the filter working, and 2) get the result displayed.

The object browser is a great source of help. Press f2 in the VBA environment, then switch from <All Libraries> to Outlook. Select Items left hand, and its Restrict function right hand. Press f1 for help. There´s a list of all properties that cannot be used with the Restrict function, or Find respectively.

ConversationIndex cannot be used, ConversationID is not mentioned. However, I tried it myself and get the same error. So I´d also conclude it´s not supported.

What about the ConversationTopic property? That one does work with the Restrict function.
Michael, thanks again for responding. I've scoured the internet for an answer to this dilemma and can find nothing. I believe the ConversationTopic is a property that can be easily changed if someone in the conversation thread changes some component, say the Subject line. The ConversationID would remain the same, I think. I can get that number all day long through mailitem.GetConversation, but I can find no way to display ONLY the messages associated with that ConversationID. A great shortcoming in Outlook. Perhaps MS is working on it. If not, they should.

In the meantime, I'm creating a table in the Access database and copying every email to it (all the important parts), and controlling the sending of responses inside the database. I can associate all these entries with the correct Work Order, and provide the user with a conversation thread associated with that Work Order.

If you run across another solution, I'd love to hear about it. Again, many thanks for your help.

Jim H.
Are you sure the ConversationID doesn´change? Since it´s computed, I´d expect it to change, too, when the topic is changed.

BTW: The Outlook object model doesn`t allow to change the topic, you´d need to dig deeper. And changing the subject has no effect on the Conversation.
Ok, Michael. I'll look into that. I'd much rather have Outlook handle all the email requirements. Many thanks.
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
S rule, automatic replies, restricting them to within the company Using Outlook 1
J Restricting access to certain features for specific users BCM (Business Contact Manager) 3
L Cannot open PST file for first session each day Using Outlook 6
M McAllister Outlook stops Sending/Receiving/Synching after disconnecting remote desktop session Using Outlook 2
D Creating an outlook session from Access vba but run silently. With A specific profile Outlook VBA and Custom Forms 1
M VBA Auto-Reply code for Two Mailboxes on one Outlook Session. Outlook VBA and Custom Forms 4
S Failed to create an RDO session instance: Class not registered Outlook VBA and Custom Forms 1
P CDO MAPI Session failing to retrieve user name but Getexchage user Outlook VBA and Custom Forms 2
P Limited Support for 3rd Party Mail in new Outlook? Using Outlook 1
T Exchange Server - Mail Delay Stamping Exchange Server Administration 0
L Error when exporting Sent Mail to Excel Outlook VBA and Custom Forms 6
X Run macro automatically when a mail appears in the sent folder Using Outlook 5
K How can I delete an e-mail from Outlook Using Outlook 1
L Help: set flag for sent mail to check if received an answer Outlook VBA and Custom Forms 2
A Macro Mail Alert Using Outlook 4
e_a_g_l_e_p_i MY Outlook 2021 changed the format of the shortcuts for mail, calendar etc. Using Outlook 10
Z Outlook 365 Automatically assign categories to incoming mail in a shared folder Round Robin Outlook VBA and Custom Forms 1
W Outlook 365 I am getting the "Either there is no default mail client" error when I try to send an email on excel Office 365 Using Outlook 1
D Gmail mail is being delivered to a different email inbox in Outlook App 2021 Using Outlook 2
P What is your strategy for dealing with SPAM and Junk Mail? Using Outlook 1
C Code to move mail with certain attachment name? Does Not work Outlook VBA and Custom Forms 3
T 1:1 Datatransfer from incoming mail body to customs form body Outlook VBA and Custom Forms 0
O Mail rule issue Using Outlook 3
A manual rule sends mail to wrong folder Using Outlook 5
Aussie Outlook 365 Rule runs manually but returns the error code "an unexpected error has occurred" when incoming mail arrives Using Outlook 1
D ISOmacro to extract active mail senders name and email, CC, Subject line, and filename of attachments and import them into premade excel spread sheet Outlook VBA and Custom Forms 2
Witzker Outlook 2019 Macro to answer a mail with attachments Outlook VBA and Custom Forms 2
D Outlook 2003 Mail Fails Using Outlook 1
Cathy Rhone Mail merge error message Using Outlook 1
R Sent emails show iCloud mail account not the alias Using Outlook 2
D Advanced e-Mail search on from/to contact group only searches for first 20 contacts in group Using Outlook 0
P Print attachments automatically and move the mail to an existing folder called "Ted" Outlook VBA and Custom Forms 4
P Importing other e-mail accounts into Outlook Using Outlook 1
lcarpay Stay in the mail folder pane after ctrl-1 Using Outlook 1
O Exchange Sync period only (e.g. last years mail) Using Outlook 0
F Excel VBA to move mails for outlook 365 on secondary mail account Outlook VBA and Custom Forms 1
M Convertor for Outlook Express Mail Store (.dbx) to Outlook Mail Store (.pst) Using Outlook 0
T vba extract data from msg file as attachment file of mail message Outlook VBA and Custom Forms 1
J E-mail held in Outbox while Minimized Using Outlook 3
G Forward email body to other mail list directly from Exchange server Exchange Server Administration 1
T Outlook creates a copie of every mail I send Using accounts in Outlook 4
N Please advise code received new mail Using Outlook 0
M Outlook 2010 How could I globally redesign an outlook template form/region/inspector template used to display mail lists or an individual mails? Outlook VBA and Custom Forms 0
A How to stop user form from disapearing once mail window is closed? Outlook VBA and Custom Forms 0
M Outlook, send to > mail recipient - results in plain text email Using Outlook 1
R How to Sync *all* Google Workspace Mail Folders with Outlook 2019 (MS365) Using Outlook 3
S Outlook VBA How to adapt this code for using in a different Mail Inbox Outlook VBA and Custom Forms 0
E Having some trouble with a run-a-script rule (moving mail based on file type) Outlook VBA and Custom Forms 5
S Outlook email to configure setup for each mail Outlook VBA and Custom Forms 1
L Correct E-Mail Pulling Wrong Mail Using Outlook 5

Similar threads