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
| Function lecture_mail(mail As Variant) As Variant
Dim tableau As Integer
Dim validation As Integer
Dim tabl(1 To 9) As String
Dim test As Variant
' Séparation du corps du mail par des retours chariot
test = Split(mail, Chr(10))
' Débogage si le système est erroné dans une nouvelle demande
' MsgBox (mail)
For i = 0 To (UBound(test) - 1)
Application.WorksheetFunction.Trim (test(i))
Next i
' Recherche du Système pour détecter le debut tableau (Cat1,Cat2,Cat3,Cat4...)
' Il y a une validation, il faut que le mot système et Produit apparaissent avant le nom du système
tableau = 0
validation = 0
While (test(tableau) <> ("Cat1" & Chr(13)) And test(tableau) <> ("Cat2" & Chr(13)) And test(tableau) <> ("Cat3" & Chr(13)) _
And test(tableau) <> ("Cat4" & Chr(13)) And test(tableau) <> ("Cat5" & Chr(13)) And test(tableau) <> ("Cat6" & Chr(13)) _
And test(tableau) <> ("Cat7" & Chr(13)) And test(tableau)<> (Chr(160) & "Cat8" & Chr(13)) Or validation < 2) _
And test(tableau) <> ("Cat9" & Chr(13)) And test(tableau) <> ("AUTRE" & Chr(13)) _
And tableau <= (UBound(test) - 1)
If test(tableau) = ("A" & Chr(13)) Or test(tableau) = ("B" & Chr(13)) _
Or test(tableau) = ("C" & Chr(13)) Then
validation = validation + 1
End If
tableau = tableau + 1
Wend
If validation >= 2 Then
' Récupération des informations dans le tableau (A / B / C / D /
' E / F/ G)
For i = 1 To 9
tabl(i) = test(tableau + (i - 1) * 2)
Next i
Else
For i = 1 To 9
tabl(i) = ""
Next i
End If
lecture_mail = tabl
End Function |
Partager