Insertion de texte dans une macro de création d'email
Bonjour à tous,
Je souhaiterais travailler le corps de mon message en VBA dans une macro pour envoyer un mail.
La partie rouge est celle où j'aurais besoin de vos lumières. Je souhaiterais entrer un message type:
Bonjour X,
strbody1 correspondant au texte figurant en B6 (comme fait plus bas)
Ainsi que ma signature à la fin en intégrant un espace entre le Bonjour X, le strbody1 et ma signature.
Ci-joint ma macro:
Code:
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 46 47 48 49 50 51 52
| Application.DisplayAlerts = False
Application.ScreenUpdating = False
Sheets("RECAP").Activate
Dim OutApp1 As Object
Dim OutMail1 As Object
Dim strbody1 As String
Dim destinatairelist1 As Variant
Dim subject1 As Variant
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Windows("DAILY EMAILS.xlsm").Activate
Sheets("RECAP").Activate
Set OutApp1 = CreateObject("Outlook.Application")
OutApp1.Session.Logon
Set OutMail1 = OutApp1.CreateItem(0)
strbody1 = Range("B6") ' <========
strbody1 = Range("B6")
subject1 = Range("E5")
Set destinatairelist1 = Range("A2")
On Error Resume Next
With OutMail1
.Display
.To = destinatairelist1
.CC = "XX@XX.com"
.BCC = ""
.Subject = subject1
.HTMLBody = "<font face=""Calibri"" size=""3"">" & strbody1 & "<br>" & .HTMLBody
.Display
End With
On Error GoTo 0
Set OutMail1 = Nothing
Set OutApp1 = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub |
Merci bien !