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
|
Sub outlook_import_emailbody()
Dim o As Outlook.Application
Set o = New Outlook.Application
Dim ons As Outlook.Namespace
Set ons = o.getNamespace("MAPI")
Dim oOLApp As Outlook.Application
Dim oOLXplr As Outlook.Explorer
Dim oOLFldInbox As Outlook.Folder, oOLFld As Outlook.Folder
' Remplacez "Test" par le nom exact du sous-dossier que vous souhaitez traiter
Dim MYFOL As Outlook.Folder
Set MYFOL = ons.GetDefaultFolder(olFolderInbox).Parent
MsgBox MYFOL
Set MYFOL = ons.GetDefaultFolder(olFolderInbox).Parent.Folders("Courrier indésirable")
MsgBox MYFOL
'
Dim omail As Outlook.MailItem
Dim R As Long
'ong = "Mail en Erreur"
ligne = 4
Dim bodyText As String
' Boucle pour parcourir les e-mails et extraire les informations requises
For Each omail In MYFOL.Items
' Extraire les caractères Ã* partir des mots-clés spécifiés
bodyText = omail.Body
' Recherche du mot-clé "la livraison de votre véhicule immatriculé"
Dim addresse_mail As String
cle_adresse = "@"
clé_id = InStr(1, bodyText, cle_adresse)
'reconstitution de l'adresse mail
k = 1
While Mid(bodyText, clé_id - k, 1) <> ":"
k = k + 1
Wend
debut_add = clé_id - k + 1
k = 1
While Mid(bodyText, clé_id + k, 1) <> "D"
k = k + 1
Wend
fin_add = clé_id + k - 1
adresse_mail = Mid(bodyText, debut_add, fin_add - debut_add)
'écriture du mail recherché
'Worksheets(ong).
Cells(ligne, 1).Value = adresse_mail
ligne = ligne + 1
' End If
Next omail
Set o = Nothing
Set ons = Nothing
Set MYFOL = Nothing
Set omail = Nothing
End Sub |
Partager