Bonjour à tous,
----> Macro Outlook.
Je dispose d'une macro pour que lorsque je reçois un nouveau mail d'une adresse fixe celui-ci se transfère automatiquement vers d'autres adresses en fonction d'un mot dans l'objet de l'email.
J'ai deux choses à améliorer pour lesquelles j'aimerai votre expertise svp :
-> Choisir l'adresse de l'expéditeur sur lequel s'exécute la macro.
-> Exécuter la macro uniquement sur le dernier e-mail reçu.
Un grand merci pour l'aide que vous pourrez m'apporter.
Kasminator
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Private Sub Application_NewMailEx(ByVal EntryIDCollection As String) Dim objCurrentFolder As Folder Dim objVariant As Variant Dim objForwardMail As MailItem Dim i As Long Set objCurrentFolder = Outlook.Application.ActiveExplorer.CurrentFolder For i = objCurrentFolder.Items.Count To 1 Step -1 If TypeOf objCurrentFolder.Items.Item(i) Is MailItem Then Set objVariant = objCurrentFolder.Items.Item(i) If InStr(LCase(objVariant.Subject), "888888888") > 0 Then Set objForwardMail = objVariant.Forward With objForwardMail .To = "KASMINATOR@MINA.fr" .Send End With End If If InStr(LCase(objVariant.Subject), "99999999") > 0 Then Set objForwardMail = objVariant.Forward With objForwardMail .To = "MINATOR22@MINA.fr" .Send End With End If End If Next i End Sub
Partager