title: Getting an EntryID after an object is moved
body: <h2>Summary</h2>
  <p>I'm trying to add hyperlinks to tasks created from emails that I have moved to another folder.</p>
  <p>The goal is to have the task contain a hyperlink to the Outlook item that was moved to a &quot;Processed Email&quot; folder&quot;.</p>
  <h2>Problem</h2>
  <p>I don't understand how to move a MailItem and then get its new EntryID after it moves.</p>
  <p>The &quot;naive&quot; way doesn't work. After using the Move method to move a MailItem object, the EntryID property does not reflect a change in ID.</p>
  <h2>Details</h2>
  <p>Creating a hyperlink to an Outlook item using the format <code>outlook:&lt;EntryID&gt;</code> is easy enough if the Outlook item remains in the Inbox, since I can just get the EntryID of the object that I am linking to. However, Outlook changes the EntryID when an object is moved.</p>
  <p>I want to understand how to get the updated ID so that I can construct an accurate link.</p>
  <h3>Example</h3>
  <p>The message boxes show the EntryID property of objMail returns the same value despite the fact that the object has moved. However, running a separate macro on the mail in the destination folder confirms that the EntryID has changed with the move.</p>
  <pre class="lang-vb prettyprint-override"><code>Sub MoveObject(objItem As Object)
    
  Select Case objItem.Class
  Case olMail
  
      Dim objMail As MailItem
      Set objMail = objItem
  
      MsgBox (objMail.EntryID)
          
      Dim inBox As Outlook.MAPIFolder
      Set inBox = Application.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
      Dim destFolder As Outlook.MAPIFolder
      Set destFolder = inBox.Folders(&quot;Processed Email&quot;)
      If (Application.ActiveExplorer().CurrentFolder.Name &lt;&gt; destFolder.Name) Then 
          objMail.Move destFolder
      End If
      MsgBox (objMail.EntryID)
  End Select
  End Sub
  </code></pre>