Bonjours,
J’ai trouver ce code dans la faq ,(Comment envoyer un mail avec Outlook ? de Etienne Bar)
Mais comment l'utiliser à partir d'un bouton sur formulaire ?
Call CreateEmai ne fonctionne pas
Merci pour votre aide
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 Public Sub CreateEmail( _ Recipient As String, _ Subject As String, _ Body As String, _ Optional Attach As Variant) ' -------------------------- Dim I As Integer Dim oEmail As Outlook.MailItem Dim appOutLook As Outlook.Application ' Créer un nouvel item mail Set appOutLook = New Outlook.Application Set oEmail = appOutLook.CreateItem(olMailItem) ' Les paramètres oEmail.To = Recipient oEmail.Subject = Subject oEmail.Body = Body If Not IsMissing(Attach) Then If TypeName(Attach) = "String" Then ' S'il y a des pièces jointes oEmail.Attachments.Add Attach Else For I = 0 To UBound(Attach) - 1 oEmail.Attachments.Add Attach(I) Next End If End If ' Envoie le message oEmail.Send ' Détruit les références aux objets Set oEmail = Nothing Set appOutLook = Nothing End Sub
Partager