Bonjour j'ai une question urgente...

j'ai essayé de construire un code permettant d'envoyer un mail via mon interface access 2007. ce mail par correctement avec le code suivant:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
Dim appOutLook As Outlook.Application
                    Dim MailOutLook As Outlook.MailItem
                    Set appOutLook = CreateObject("Outlook.Application")
                    Set MailOutLook = appOutLook.CreateItem(olMailItem)
                    Set appOutLook = CreateObject("Outlook.Application")
                    Set MailOutLook = appOutLook.CreateItem(olMailItem)
                    With MailOutLook
                            .To = "mon-email@domaine.eu"
                            .Subject = "Form. N°" + Str(id.Value) + " - Status : " + Me.Status.Value
                            .Body = " Ussuer comment : " & Me.Commentaire1.Value & "    ( Clic here for open the document : \\cheminreseau\archives\" & Me.id.Value & ".xlsm )"
                            .Send
                    End With
                    MsgBox "Your message is good sended at Christophe  !"
Juste là tout va bien !

Mais j'ai une fonction à intégrer qui rend la chose "conditionnelle" !

J'ai un champ "BU-Manager" qui contient un login de 4 digit, et je voudrais que si ce champ est complété, ben que le mail soit transmis à qui de droit...

j'ai écris donc ce code... mais cela ne va pas, qui saurait me dire pourquoi ... je galère trop pfff

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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
If Me.BU_Manager = "Choose here !" Then
    MsgBox "Please choose the BU MANAGER ! "
 
    Else
 
    If Me.BU_Manager = "Pigi" Then
 
        Dim appOutLook As Outlook.Application
        Dim MailOutLook As Outlook.MailItem
        Set appOutLook = CreateObject("Outlook.Application")
        Set MailOutLook = appOutLook.CreateItem(olMailItem)
        Set appOutLook = CreateObject("Outlook.Application")
        Set MailOutLook = appOutLook.CreateItem(olMailItem)
        With MailOutLook
                .To = "contact1@domaine.eu"
                .Subject = "R.A.P. N°" + Str(id.Value) + " - Status : " + Me.Status.Value
                .Body = " Ussuer comment : " & Me.Commentaire1.Value & "    ( Clic here for open the document : \\cheminreseau\\" & Me.id.Value & ".xlsm )"
                .Send
        End With
        MsgBox "Your message is good sended at contact1 !"
 
    Else
 
        If Me.BU_Manager = "SeAn" Then
 
            Dim appOutLook As Outlook.Application
            Dim MailOutLook As Outlook.MailItem
            Set appOutLook = CreateObject("Outlook.Application")
            Set MailOutLook = appOutLook.CreateItem(olMailItem)
            Set appOutLook = CreateObject("Outlook.Application")
            Set MailOutLook = appOutLook.CreateItem(olMailItem)
            With MailOutLook
                    .To = "contact2@domaine.eu"
                    .Subject = "R.A.P. N°" + Str(id.Value) + " - Status : " + Me.Status.Value
                    .Body = " Ussuer comment : " & Me.Commentaire1.Value & "    ( Clic here for open the document : \\cheminreseau\\" & Me.id.Value & ".xlsm )"
                    .Send
            End With
            MsgBox "Your message is good sended at contact2 !"
 
        Else
 
            If Me.BU_Manager = "JcPa" Then
 
                Dim appOutLook As Outlook.Application
                Dim MailOutLook As Outlook.MailItem
                Set appOutLook = CreateObject("Outlook.Application")
                Set MailOutLook = appOutLook.CreateItem(olMailItem)
                Set appOutLook = CreateObject("Outlook.Application")
                Set MailOutLook = appOutLook.CreateItem(olMailItem)
                With MailOutLook
                        .To = "contact3@domaine.eu"
                        .Subject = "R.A.P. N°" + Str(id.Value) + " - Status : " + Me.Status.Value
                        .Body = " Ussuer comment : " & Me.Commentaire1.Value & "    ( Clic here for open the document : \\cheminreseau\\" & Me.id.Value & ".xlsm )"
                        .Send
                End With
                MsgBox "Your message is good sended at contact3 !"
 
            Else
 
                If Me.BU_Manager = "Arta" Then
 
                    Dim appOutLook As Outlook.Application
                    Dim MailOutLook As Outlook.MailItem
                    Set appOutLook = CreateObject("Outlook.Application")
                    Set MailOutLook = appOutLook.CreateItem(olMailItem)
                    Set appOutLook = CreateObject("Outlook.Application")
                    Set MailOutLook = appOutLook.CreateItem(olMailItem)
                    With MailOutLook
                            .To = "contact4@domaine.eu"
                            .Subject = "R.A.P. N°" + Str(id.Value) + " - Status : " + Me.Status.Value
                            .Body = " Ussuer comment : " & Me.Commentaire1.Value & "    ( Clic here for open the document : \\cheminreseau\\" & Me.id.Value & ".xlsm )"
                            .Send
                    End With
                    MsgBox "Your message is good sended at Contact4 !"
 
                Else
 
                    Dim appOutLook As Outlook.Application
                    Dim MailOutLook As Outlook.MailItem
                    Set appOutLook = CreateObject("Outlook.Application")
                    Set MailOutLook = appOutLook.CreateItem(olMailItem)
                    Set appOutLook = CreateObject("Outlook.Application")
                    Set MailOutLook = appOutLook.CreateItem(olMailItem)
                    With MailOutLook
                            .To = "contact5@domaine.eu"
                            .Subject = "R.A.P. N°" + Str(id.Value) + " - Status : " + Me.Status.Value
                            .Body = " Ussuer comment : " & Me.Commentaire1.Value & "    ( Clic here for open the document : \\cheminreseau\archives\" & Me.id.Value & ".xlsm )"
                            .Send
                    End With
                    MsgBox "Your message is good sended at Contact5 !"
 
                End If
            End If
        End If
    End If
 End If
End Sub