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
| Sub ITDClos()
Dim myFolder As MAPIFolder
Dim Item As Variant 'MailItem
Dim xlApp As Object 'Excel.Application
Dim xlWB As Object 'Excel.Workbook
Dim xlSheet As Object 'Excel.Worksheet
Dim xlRow As Long
Dim Keys(100)
Dim Lines() As String
Dim I As Long, J As Long, P As Long
.....
Set xlWB = xlApp.Workbooks.Add 'Add a new workbook
Set xlSheet = xlWB.ActiveSheet
xlRow = 1
Set myFolder = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox) 'Access the outlook inbox folder
Set myFolder = myFolder.Folders("ANOMALIES")
'Visit all mails
For Each Item In myFolder.Items
If TypeOf Item Is MailItem Then
MyString = Item.Subject
FirstWord = Mid(MyString, 1, 10) ' Renvoie les 10 premiers car. du sujet du mail
If FirstWord = "ANOMALIE 1" Then ' Verifie si objet du mail contient les anomalies 1
Lines = Split(Item.Body, vbCrLf)
J = 0
For I = 0 To UBound(Lines)
A = Mid(Lines(I), 4, 3)
B = Mid(Lines(I), 4, 7)
C = Mid(Lines(I), 4, 9)
D = Mid(Lines(I), 4, 6)
If B = "REF-PRD" Then
xlSheet.Cells(xlRow, J + 1) = Mid(Lines(I), 16)
xlSheet.Cells(xlRow, J + 7) = "Anomalie 1"
End If
If B = "REF-CTR" Then
xlSheet.Cells(xlRow, J + 2) = Mid(Lines(I), 16)
xlSheet.Cells(xlRow, J + 7) = "Anomalie 1"
End If
If C = "PROGRAMME" Then ' à vérifier
xlSheet.Cells(xlRow, J + 3) = Mid(Lines(I), 16)
xlSheet.Cells(xlRow, J + 7) = "Anomalie 1"
End If
If A = "MSG" Then
xlSheet.Cells(xlRow, J + 4) = Mid(Lines(I), 16)
xlSheet.Cells(xlRow, J + 7) = "Anomalie 1"
End If
If D = "METIER" Then ' à vérifier
xlSheet.Cells(xlRow, J + 5) = Mid(Lines(I), 16)
xlSheet.Cells(xlRow, J + 7) = "Anomalie 1"
End If
If C = "SITE DEST" Then
xlSheet.Cells(xlRow, J + 6) = Mid(Lines(I), 16)
xlSheet.Cells(xlRow, J + 7) = "Anomalie 1"
End If
Next
xlRow = xlRow + 1
End If
End If
Next |
Partager