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
| 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
Set appOutLook = New Outlook.Application
Set oEmail = appOutLook.CreateItem(olMailItem)
oEmail.To = Recipient
oEmail.Subject = Subject
oEmail.Body = Body
If Not IsMissing(Attach) Then
If TypeName(Attach) = "String" Then
oEmail.Attachments.Add Attach
Else
For I = 0 To UBound(Attach) - 1
oEmail.Attachments.Add Attach(I)
Next
End If
End If
oEmail.send
Set oEmail = Nothing
Set appOutLook = Nothing
DoCmd.Close
End Sub |
Partager