<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Show Parrent Account in Outlook Contact</title>
	<atom:link href="http://mscrm.m-seidl.com/2007/03/22/show-parrent-account-in-outlook-contact/feed/" rel="self" type="application/rss+xml" />
	<link>http://mscrm.m-seidl.com/2007/03/22/show-parrent-account-in-outlook-contact/</link>
	<description></description>
	<pubDate>Tue, 07 Sep 2010 21:26:40 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: Eivind Sandstrand</title>
		<link>http://mscrm.m-seidl.com/2007/03/22/show-parrent-account-in-outlook-contact/#comment-296</link>
		<dc:creator>Eivind Sandstrand</dc:creator>
		<pubDate>Sun, 30 Nov 2003 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://mscrm.m-seidl.com/2007/03/22/show-parrent-account-in-outlook-contact/#comment-296</guid>
		<description>Here's the code to fix the problem:



Set it as a macro and run it periodically to make sure you Outlook contacts have the CRM Parent Account name set



Sub SyncCRMCompanyName()
  Dim objApp As Application
  Dim objNS As NameSpace
  Dim objContacts As MAPIFolder
  Dim colItems As Items
  Dim objContact As ContactItem
  Dim strParentAcct As String
  Dim i As Integer
  
  Set objApp = CreateObject("Outlook.Application")
  Set objNS = objApp.GetNamespace("MAPI")
  Set objContacts = objNS.GetDefaultFolder(olFolderContacts)
  i = 0

  Set colItems = objContacts.Items
  For Each objContact In colItems
   strParentAcct = ""
   If objContact.CompanyName = "" Then
        If objContact.UserProperties.Count &#62; 0 Then
            strParentAcct = objContact.UserProperties.Item("Parent Account")
            If strParentAcct  "" Or objContact.CompanyName  strParentAcct Then
                Rem Answer = MsgBox(strParentAcct, vbOKCancel)
                objContact.CompanyName = strParentAcct
                objContact.Save
                i = i + 1
            End If
        End If
    End If
    
  Next
  MsgBox ("All done: " &#38; i &#38; " records updated")
End Sub</description>
		<content:encoded><![CDATA[<p>Here&#8217;s the code to fix the problem:</p>
<p>Set it as a macro and run it periodically to make sure you Outlook contacts have the CRM Parent Account name set</p>
<p>Sub SyncCRMCompanyName()<br />
  Dim objApp As Application<br />
  Dim objNS As NameSpace<br />
  Dim objContacts As MAPIFolder<br />
  Dim colItems As Items<br />
  Dim objContact As ContactItem<br />
  Dim strParentAcct As String<br />
  Dim i As Integer</p>
<p>  Set objApp = CreateObject(&#8221;Outlook.Application&#8221;)<br />
  Set objNS = objApp.GetNamespace(&#8221;MAPI&#8221;)<br />
  Set objContacts = objNS.GetDefaultFolder(olFolderContacts)<br />
  i = 0</p>
<p>  Set colItems = objContacts.Items<br />
  For Each objContact In colItems<br />
   strParentAcct = &#8220;&#8221;<br />
   If objContact.CompanyName = &#8220;&#8221; Then<br />
        If objContact.UserProperties.Count &gt; 0 Then<br />
            strParentAcct = objContact.UserProperties.Item(&#8221;Parent Account&#8221;)<br />
            If strParentAcct  &#8220;&#8221; Or objContact.CompanyName  strParentAcct Then<br />
                Rem Answer = MsgBox(strParentAcct, vbOKCancel)<br />
                objContact.CompanyName = strParentAcct<br />
                objContact.Save<br />
                i = i + 1<br />
            End If<br />
        End If<br />
    End If</p>
<p>  Next<br />
  MsgBox (&#8221;All done: &#8221; &amp; i &amp; &#8221; records updated&#8221;)<br />
End Sub</p>
]]></content:encoded>
	</item>
</channel>
</rss>
