title: Outlook does not recognize one or more names
body: <p>I have following vba code which reads a mailbox and sends reply to any users who send a invalid code as a reply to the mailbox, but sometimes the run time error (Outlook does not recognize one or more names) is received. My questions are,</p>
  
  <ol>
  <li>Will creation of new MAPI profile resolve the issue or do i need to add a code that resolves the address and ignores if the email id no longer exist. if yes how do i do that?</li>
  <li>Also in general whats the parameter to not send emails for specific condition?</li>
  </ol>
  
  <p>Below is the code that we currently have:</p>
  
  <pre><code>      Sub ResponseCodeError(Item As Outlook.MailItem)
        'If not a valid code then send email to the User
        If (Left(Item.Subject, 2) &lt;&gt; "S;" And Left(Item.Subject, 2) &lt;&gt; "N;") Then
        Dim outobj, mailobj
        Set outobj = CreateObject("Outlook.Application")
        Set mailobj = outobj.CreateItem(0)
        With mailobj
       .To = Item.SenderEmailAddress
       .Subject = "Invalid Code"
       .Body = "Please use a valid CODE"
       .Send
        End With
       'Move Email to Error Folder
       mailboxNameString = "mailboxname"
       FolderName = "Error"
  
       Dim olApp As New Outlook.Application
       Dim olNameSpace As Outlook.NameSpace
       Dim olCurrExplorer As Outlook.Explorer
       Dim olCurrSelection As Outlook.Selection
       Dim olDestFolder As Outlook.MAPIFolder
  
       Set olNameSpace = olApp.GetNamespace("MAPI")
       Set olCurrExplorer = olApp.ActiveExplorer
       Set olCurrSelection = olCurrExplorer.Selection
       Set olDestFolder = olNameSpace.Folders(mailboxNameString).Folders(FolderName)
  
       Item.Move olDestFolder
  
       End If
  
       Set outobj = Nothing
       Set mailobj = Nothing
       End Sub
  </code></pre>