Bonjour,
Je cherche a ajouter la signature par défaut d'outlook sur les mails qui sont généré via vba.
Mon fichiers est sur le réseau de mon entreprise et peut être utilisé par tout les utilisateurs donc il est impératif que ces mail soient signé par l'utilisateur.
Voici mon code actuel :
Option Explicit
Sub Envoyer_Mail_Outlook()
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\VBA\Condition de retour.pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Dim Sh, nSh As Worksheet
Dim nWb As Workbook
Dim aApp, aMail As Object
Dim FilePath$
Set Sh = ThisWorkbook.Sheets("CONDITION DE RETOUR") 'choisir la bonne feuille
Set nWb = Workbooks.Add()
Set nSh = nWb.Sheets(1)
Set aApp = CreateObject("Outlook.Application")
Set aMail = aApp.CreateItem(0)
Application.ScreenUpdating = False
Sh.Cells.Copy nSh.Range("A1")
FilePath = "C:\VBA\Condition de retour.pdf" 'Choisir un path (peu importe lequel puisqu'on écrase le fichier à la fin)..
With aMail
.To = Range("M2")
.Subject = "Reprise de marchandise suite non-conformité N°" & Range("G11").Value
.Body = Range("L6").Value & Chr(13) & Range("L7").Value & Chr(13) & Range("L8").Value & Chr(13) & Range("L9").Value & Chr(13) & Range("L10").Value & Chr(13) & Range("L11").Value & Chr(13) & Range("L12").Value
.Attachments.Add FilePath 'On rajoute le fichier créé.
.Send 'ou .Display pour afficher le mail.
End With
nWb.Close False 'On ferme le fichier...
Kill FilePath 'et on le détruit.
Set Sh = Nothing
Set nSh = Nothing
Set nWb = Nothing
Set aMail = Nothing
Set aApp = Nothing
End Sub