Bonjour à tous,

Je viens de créer un bouton sur un formulaire Access qui va me permettre d'envoyer un mail via Outllok

voila le code

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
 
 
Public Sub SendOLMail_Click()
 
Dim strEmail As String
Dim strObj As String
Dim strMsg As String
Dim blnEdit As Boolean
 
Dim ol As Outlook.Application
Dim mi As Outlook.MailItem
 
' Créer une instance d'Outlook
On Error GoTo OLMailErr
Set ol = New Outlook.Application
 
' Créer un objet Email
Set mi = ol.CreateItem(olMailItem)
 
' Paraméter le message
With mi
  .To = "coco@mail.com"
  .Subject = "test"
  .Body = "c'est un test"
  .Display
 
  End If
End With
 
Set mi = Nothing
Set ol = Nothing
Exit Sub
 
OLMailErr:
    MsgBox "Erreur : " & Err.Number & vbCrLf & Err.Description
    Exit Sub
End Sub
 
End Sub
Et voila ce que ca me retourne:

Compile error:
User-defied type not defined

Et ca m'indique la ligne

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
Dim ol As Outlook.Application
Il semblerait que j'ai un problème de référencement de outlook mais je ne sais pas du tout comment faire pour le référencer. Je suis sur MS Access 2010 et Outlook 2010.
Merci d'avance pour votre aide.
Cordialement