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
|
Function EnvoiMail(AdrCible As String, Sujet As String, Corps As String, Pj As String) As Boolean
Dim appOutLook As outlook.Application
Dim oMail As MailItem
On Error GoTo err
EnvoiMail = True
If IsOfficeRunning(App_Outlook, True) Then
'outlook est ouvert
MsgBox "outlook running", vbOKOnly, "vérification office"
Set appOutLook = GetObject("", "Outlook.Application")
Else
'outlook est fermé
Set appOutLook = CreateObject("Outlook.Application")
End If
Set oMail = appOutLook.CreateItem(olMailItem)
oMail.To = AdrCible
oMail.Subject = Sujet
oMail.Body = Corps
oMail.Attachments.Add (Pj)
oMail.Display
'oMail.Send
GoTo finally
err:
MsgBox err.Description + Str(err.Number), vbCritical, "Fonction : EnvoiMail - Module : 02Mail"
Exit Function
finally:
On Error Resume Next
Set oMail = Nothing
Set appOutLook = Nothing
End Function |
Partager