Bonjour,
j'ai créé une macro qui va ajouter suivant l'adresse mail de l'expéditeur un numéro de client (chaque client est identifié par un numéro suivant son mail dans un fichier .csv).
Tout se passe bien quand c'est un mail 'normal' mais dès qu'il s'agit d'un mail spécial (non remis par exemple), cela plante !
Qui connaît la condition à tester et surtout où l'insérer ?
Merci d'avance pour votre aide.
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim t() As String
Dim MonApp As Outlook.Application
Dim MonMail As Object
Dim MonNameSpace As Outlook.NameSpace
Dim MonDossier As Outlook.Folder
Set MonApp = Outlook.Application
Set MonNameSpace = MonApp.GetNamespace("MAPI")
Set MonDossier = MonNameSpace.GetDefaultFolder(olFolderInbox)
Set MonMail = Application.Session.GetItemFromID(EntryIDCollection)
b = MonMail.SenderEmailAddress
c = 0
If InStr(b, "[>") = 0 Then
Open "c:\temp\ia\publipostage.csv" For Input As #1
Line Input #1, a$
While (Not EOF(1) And c = 0)
Line Input #1, a$
t = Split(a$, ";")
If t(1) = b Then
c = 1
MonMail.Subject = "[>" & Right$("00000" & t(0), 5) & "<]" & MonMail.Subject
MonMail.Save
End If
Wend
Close #1
If c = 0 Then
Open "c:\temp\ia\collaborateurs.csv" For Input As #1
While (Not EOF(1) And c = 0)
Line Input #1, a$
t = Split(a$, ";")
If t(3) = b Then
c = 1
MonMail.Subject = "[-->" & Right$("00000" & t(0), 5) & "<--]" & MonMail.Subject
MonMail.Save
End If
Wend
Close #1
End If
End If
End Sub
Partager