Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
strbody = "Bonjour" & vbNewLine & vbNewLine & _
"" & vbNewLine & _
" le fichier de gestion des PRIMAIRES a été modifié le " & Now & " par " & Environ("UserName") & " De plus il y a " & i & " produit(s) périmé(s)" & vbNewLine & vbNewLine & _
"Ce mail est généré automatiquement" & vbNewLine & _
"" & vbNewLine & _
"" & vbNewLine & _
"Veuillez ne pas repondre" & vbNewLine & _
""
On Error Resume Next
With OutMail
.To = "pex@aol.fr"
.Cc = ""
.Bcc = ""
.Subject = "Suivi fichier gestion des stocks PRIMAIRES"
.Body = strbody
'ou .display pour un envoie accepter'
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub