1
votes

I'm writing a VBA macro which runs in Word 2010 on a system which has Microsoft Dynamics CRM 2011 for Microsoft Office Outlook client installed (and connected to a CRM 2011 on-premise server).

The macro is aware of the GUID for a CRM Incident and as well as doing other tasks should create an email to a contact connected to that Incident and then "Set Regarding" the email to point to the correct Incident record. I can do everything apart from "Set Regarding" programmatically.

I discovered in this article Crm 2011 outlook client - Set regarding mandatory that when you Set Regarding via the Outlook client GUI, it creates 4 UserProperties on the email item.

I've tried to replicate this by creating the 4 user properties:-

res = oItem.UserProperties.Add("crmLinkState", 3)
oItem.UserProperties("crmLinkState").Value = 1
res = oItem.UserProperties.Add("crmRegardingId", 1)
oItem.UserProperties("crmRegardingId").Value = MatterGUID
res = oItem.UserProperties.Add("crmRegardingObjectType", 1)
oItem.UserProperties("crmRegardingObjectType").Value = 112
res = oItem.UserProperties.Add("Regarding", 1)
oItem.UserProperties("Regarding").Value = MatterDescription

This causes the Outlook email item to show the regarding pane at the bottom, but it says "Regarding: none" in the pane. If you send the email it doesn't track into CRM. What should I be doing? I can't find any methods specifically for the Outlook CRM Client. Is there some oItem.SetRegarding() method I'm missing?

Any help greatly appreciated. Tony Woodhouse

1

1 Answers

3
votes

Got this working eventually.

For some reason, even though I was only displaying my mail item after creating the four custom properties, the problems I had were a sort of display / refresh glitch.

oItem.Save() after display of the item seems to force the client to re-evaluate the message properties and realise it's now a tracked message. All works fine now with just the addition of that one line of code :-)