Question : Can anyone tell me what this Outlook code does...

Hi,

Can anyone tell me what this Outlook code does...
I know i have used this a lot of times but have not recorded the action in the code...

Regards
Sharath
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
Sub ProcessMessages1()
    Dim olkMsg As Outlook.MailItem, _
        olkRecipient As Outlook.Recipient
    For Each olkMsg In Application.ActiveExplorer.Selection
        If olkMsg.Class = olMail Then
            For Each olkRecipient In olkMsg.Recipients
                CreateContact1 olkRecipient.Name, olkRecipient.Address
            Next
        End If
    Next
    Set olkMsg = Nothing
End Sub
 
Sub CreateContact1(strName As String, strAddress As String)
    Dim olkFolder As Outlook.MAPIFolder, _
        olkContact As Outlook.ContactItem
    Set olkFolder = Session.GetDefaultFolder(olFolderContacts)
    Set olkContact = olkFolder.Items.Find("[Email1Address] = '" & strAddress & "'")
    If IsNothing(olkContact) Then
        Set olkContact = Application.CreateItem(olContactItem)
        With olkContact
            .FullName = strName
            .Email1Address = strAddress
            .Save
        End With
    End If
    Set olkContact = Nothing
    Set olkFolder = Nothing
End Sub

Answer : Can anyone tell me what this Outlook code does...

To amplify I have modified ProcessMessages1 below to add the sender to the contacts folder in the same way as the recipients.

The code addition to achieve this is:

            CreateContact1 olkMsg.SenderName, olkMsg.sendereMailAddress

All other subs should be unchanged.

Chris
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Sub ProcessMessages1()
    Dim olkMsg As Outlook.mailitem, _
        olkRecipient As Outlook.Recipient
    For Each olkMsg In Application.ActiveExplorer.Selection
        If olkMsg.Class = olMail Then
            For Each olkRecipient In olkMsg.Recipients
                CreateContact1 olkRecipient.Name, olkRecipient.Address
            Next
            CreateContact1 olkMsg.SenderName, olkMsg.sendereMailAddress
        End If
    Next
    Set olkMsg = Nothing
End Sub
Random Solutions  
  •  Dropdowns in grid view 'edit item template' not working
  •  How do you import outlook express 6 messages into Windows Live Mail and have them in the proper folders?
  •  Cannot use remote executables after I upgraded to R2
  •  How do I migrate Exchange 2003 Public Folder to Exchange 2007 using PFMigrate?
  •  VPN client (Check point Secure client) not able to browse to any website on the machine once connected to the VPN.
  •  Append from Access to SQL Server key violation on any second query
  •  Expert Notify Thread - For Experts only (those answering questions in the MS Access Zone).
  •  DNS root hints not working Windows 2008
  •  can i use right([ClientName] to get the last part of a string in a Microsoft Access query if i don't know how long the last part is?
  •  How can I print using a Clipper (DOS) application under Windows 7
  •  
    programming4us programming4us