Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Updating Outlook Contacts List With Certificates from Signed Emails

Updating Outlook Contacts List With Certificates from Signed Emails

Updating Outlook Contacts List With Certificates from Signed Emails

I have a pretty extensive contacts list with custom fields and lots of filled-in and edited data. I have several hundred contacts. We are trying to send more encrypted email and now I want to update as many contacts as I can with their certificate. I cannot figure an easy way to do this manually. I think the coding pseudo code would be (assuming objects are exposed)

CODE -->

Loop messages in inbox
If the message is signed then
  If name is not on the list of downloaded certificates then
    Export certificate to folder
    add name to list
  end if
end if
next message 

At that point I could at least import the certificates relatively easily. However if possible think I could do something like this to import.

CODE -->

Loop contact list
  If contact does not have a certificate then
    loop certificate folder 
       If certificate name contains "last name" and "first name" then  (most of my certs are named "last.first.numbers.cer")
         import certificate
         save contact
         exit loop 
       end if
    next certificate
  end if
next contact 

Has anyone ever done something like this? If so would be interested in any code or pointers. Thanks.

I can loop and find digitally signed emails, but I do not see anything that exposes a digital id / Certificate object. Manually the method would be to select the sender name. Right click to "add" contact. Go to the certificate and download. I am not seeing these methods exposed either.

CODE -->

Public Sub DownLoadCerts()
   On Error GoTo errLbl
   Dim MyNameSpace As Outlook.NameSpace
   Dim MyFolder As Outlook.MAPIFolder
   Dim Item As Object
   Dim MailItem As Outlook.MailItem
   Dim counter As Integer
   Dim myList As New Collection
   Dim SenderName As String
   Dim MyContact As ContactItem
   Set MyNameSpace = GetNamespace("MAPI")
   Set MyFolder = MyNameSpace.GetDefaultFolder(olFolderInbox)
   For Each Item In MyFolder.Items
   If TypeOf Item Is Outlook.MailItem Then
         Set MailItem = Item
         If MailItem.MessageClass = "IPM.Note.SMIME.MultipartSigned" Then
           SenderName = MailItem.SenderEmailAddress
           If Not HasKey(myList, SenderName) Then
             myList.Add SenderName, SenderName 'only want to do it once per digitally signed email
             Debug.Print SenderName & " Sender"
             'Need code here to export the certificate from a email that is digitally signed
             'Debug.Print MyContact.LastNameAndFirstName & " Contact"
           End If
         End If
     End If
     counter = counter + 1
     If counter = 50 Then Exit Sub
    Next Item
    Exit Sub
    Debug.Print Err.Number & " " & Err.Description
    Resume Next
End Sub 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close