title: Programmatically "Set Regarding" - Dynamics 2011 Outlook CRM Client - VBA
body: <p>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).</p>
  
  <p>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.</p>
  
  <p>I discovered in this article <a href="https://stackoverflow.com/questions/9836718/crm-2011-outlook-client-set-regarding-mandatory">Crm 2011 outlook client - Set regarding mandatory</a> that when you Set Regarding via the Outlook client GUI, it creates 4 UserProperties on the email item.</p>
  
  <p>I've tried to replicate this by creating the 4 user properties:-</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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?</p>
  
  <p>Any help greatly appreciated.
  Tony Woodhouse</p>