title: How can i check if a mail has a valid digital signature - VBA
body: <p>I have a function that find a specific mail with subject, i also want to add some methods to find out if the mail has a valid digital signature.</p>
  
  <pre><code>Set objOutlook = CreateObject("Outlook.Application") 
  Set myNameSpace = objOutlook.GetNameSpace("MAPI")   
  Set ClientFolder = myNameSpace.GetDefaultFolder(6) 'Inbox = 6 
  Set myItems = ClientFolder.Items 
  Set myItem = myItems.GetFirst 
  Set colSyc = myNameSpace.SyncObjects
  Set syc = colSyc.AppFolders
  ClientFolder.InAppFolderSyncObject = True 
  syc.Start 'Sync inbox at most updated state
  
  For intMailCount = 0 to ClientFolder.Items.Count - 1 ' Check subject line for a match       
      If Instr(myItem.Subject, Subject) = 1 AND myItem.Unread = True then             
          VerifyEmailSubject = "True" 
  
      'validation under here does not work properly and allways returns true and need to find something here for validation
      If myItem.MessageClass &lt;&gt; "IPM.Note.SMIME" Or myItem.MessageClass &lt;&gt; "IPM.Note.Secure" Or myItem.MessageClass &lt;&gt; "IPM.Note.Secure.Sign" then
          msgbox "signed"
      End If
          myItem.Unread = false   'Set mail status to read to avoid further test assertion errors.    
      Exit For        
  End If 
      Set myItem = myItems.GetNext 
  Next 
  </code></pre>