Restricting session mail with ConversationID

Jim H.

New Member
Outlook version
Outlook 2010 32 bit
Email Account
IMAP
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)
objInbox.Display
End If
Next


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.
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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.
 

Jim H.

New Member
Outlook version
Outlook 2010 32 bit
Email Account
IMAP
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.
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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.
 

Jim H.

New Member
Outlook version
Outlook 2010 32 bit
Email Account
IMAP
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.
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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.
 

Jim H.

New Member
Outlook version
Outlook 2010 32 bit
Email Account
IMAP
Ok, Michael. I'll look into that. I'd much rather have Outlook handle all the email requirements. Many thanks.
 
Top