Private Sub Worksheet_Change(ByVal Target As Range)
k = Target.Row
If Range("F" & k).Value <> "envoi mail" Then
GoTo endsub
End If
If Range("F" & k).Value = "envoi mail" Then
       GoTo EnvoiMail
   End If
EnvoiMail:
MsgBox "voulez-vous commander ?", vbYesNo, "Stock critique"
If MsgBoxResult = vbYes Then
P = ThisWorkbook.Path
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=P & "\Commande.pdf" 'From:=1, To:=2
Dim oCDO
 
Set oCDO = CreateObject("CDO.Message")
With oCDO
  With .Configuration.Fields ' Configuration du compte mail SMTP
     .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = "2"
     .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Adresse smtp du serveur"
     .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = "numéro de port du serveur"
 
     '----- Dans le cas ou le serveur de mail demande une authentification
     .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = "1"
     .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "adresse sur le serveur utilisée pour l'envoi"
     .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mot de passe pour cette adresse "
     '----------------
     .Update
End With
  .From = "adresse sur le serveur"
 .To = "alexandre.martin@fr.issworld.com"
  .TextBody = "Texte du mail"
  .AddAttachment P & "\Commande.pdf"
  .Send
End With
Kill (P & "\Commande.pdf")
MsgBox "Une alerte mail a été envoyé au responsable des commandes"
GoTo endsub
End If
If MsgBoxResult = vbNo Then
GoTo endsub
End If
endsub:
End Sub