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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| Public RESULTAT As String
Sub CheckDistList()
'---------------------------------------------------------------------------------------
' Procedure : CheckDistList
' Author : Joseph Montecillo modifié par Oliv'
' Date : 10/10/2008
' Purpose :
'---------------------------------------------------------------------------------------
'
myDistList = InputBox("Indiquez le nom de la liste de distribution", , "test_2 listes")
Set objContactFolder = GetMAPIFolder(InputBox("Indiquez le chemin du DOSSIER CONTACTS", , "Boîte aux lettres - Olivier /Contacts/Perso"))
Dim str As String
str = "[FullName] = " & Quote & myDistList & Quote
Set objContact = objContactFolder.Items.Find(str)
RESULTAT = ""
If Not TypeName(objContact) = "Nothing" Then
If objContact.Class = 69 Then ' olDistributionList
ProcessDistributionList objContactFolder, objContact
End If
End If
'MsgBox RESULTAT
Set objApp = Outlook.Application
Dim l_Msg As Outlook.MailItem
Set l_Msg = objApp.CreateItem(olMailItem)
l_Msg.BodyFormat = olFormatPlain
l_Msg.Body = RESULTAT
l_Msg.Display
End Sub
Function ProcessDistributionList(ByRef objContactFolder, objContact)
'---------------------------------------------------------------------------------------
' Procedure : CheckDistList
' Author : Joseph Montecillo modifié par Oliv'
' Date : 10/10/2008
' Purpose :
'---------------------------------------------------------------------------------------
'
Dim y
Dim membre As Recipient
' MsgBox("Is distribution list")
For y = 1 To objContact.MemberCount
Set membre = objContact.GetMember(y)
RESULTAT = RESULTAT & vbCr & "Dist List = " & objContact & "/" & membre.Name _
& " /<" & membre.Address & ">"
If membre.Address = "Unknown" Then
Dim distrlist As DistListItem
Dim str
str = "[FullName] = " & Quote & membre.Name & Quote
Set distrlist = objContactFolder.Items.Find(str)
ProcessDistributionList objContactFolder, distrlist
End If
Next y
End Function
Function Quote()
Quote = Chr(34)
End Function
Function GetMAPIFolder(strName)
'---------------------------------------------------------------------------------------
' Procedure : CheckDistList
' Author : Joseph Montecillo modifié par Oliv'
' Date : 10/10/2008
' Purpose :
'---------------------------------------------------------------------------------------
'
Dim objNS
Dim objFolder
Dim objFolders
Dim arrName
Dim I
Dim blnFound
On Error Resume Next
Set objNS = Application.GetNamespace("MAPI")
arrName = Split(strName, "/")
blnFound = True
Set objFolders = objNS
For I = 0 To UBound(arrName)
Err = 0
Set objFolders = objFolders.Folders(arrName(I))
If Err <> 0 Then
MsgBox ("Fatal: (" & strName & ")" & vbCrLf & _
" Failed to Access folder " _
& arrName(I) & vbCrLf & " " & Err.Description)
blnFound = False
Exit For
End If
Next
If blnFound = True Then
Set GetMAPIFolder = objFolders
Else
Set GetMAPIFolder = Nothing
End If
Set objNS = Nothing
Set objFolders = Nothing
End Function |
Partager