Préformaté un texte dans VBA pour un mail avec Outlook2016

Bonjour,

J'ai un bout de code suivant :

Sub Envoipdfpoursuites()

Dim a As Integer
Dim objOutlook As Object
Dim objMail As Object
Dim rngTo As Range
Dim rngSubject As Range
Dim rngBody As String
Dim rngAttach As Range
Dim rngCC As Range
Dim ligne1 As String
Dim ligne2 As String


'enregistrement pdf
'Exporte vers PDF

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Range("I6").Value _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True

Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)

a = ActiveCell.Row

With ActiveSheet
Set rngTo = .Cells(12, 3)
Set rngSubject = .Cells(7, 9)
Set rngCC = .Cells(8, 9)
Set rngAttach = .Cells(6, 9)

End With

ligne1 = "Remplacer par un texte d'email"

With objMail
.To = rngTo.Value
.Subject = rngSubject.Value
.CC = rngCC.Value
.Body = ligne1 & "<HR>" & ligne2
.Attachments.Add rngAttach.Value
.Display 'Instead of .Display, you can use .Send to send the email _
or .Save to save a copy in the drafts folder
End With

Set objOutlook = Nothing
Set objMail = Nothing
Set rngTo = Nothing
Set rngSubject = Nothing

Set rngAttach = Nothing
End Sub

Je souhaite écrire Madame, Monsieur, puis retour à la ligne et le reste du texte : Nous vous prions de trouver en pièce jointe............

Je ne sais pas où intégrer ce texte et surtout comment ?

Hello,

Dans :

.Body =

qui donnerait qqch comme ça :

.Body = "Madame, Monsieur," & vbnewline & "Nous vous ..." 

merci infiniment. Autre question, comment changer un checkbox vrai faux par oui non. merci d'avance de votre réponse

Pour moi c'est la même chose. t'entends quoi par "changer un checkbox" ? explique ton cas

lorsque j'insère une case à cocher (contrôle activeX) , je vais dans les propriétés et dans Linkedcell, j'inscris une cellule (genre J5). le message alors apparaît VRAI FAUX à chaque clic, ALORS que je souhaiterai faire afficher oui ou non

Hello,

Franchement je ne sais pas, je ne connais pas cette propriété.

L'astuce que j'ai trouvé c'est de passer par une colonne intermédiaire avec une fonction SI

=SI(A1="VRAI";"OUI";"NON")

Merci. Mais ça me renvoie toujours VRAI FAUX

Oui, j'ai oublié de preciser que tu dois masquer la colonne linkedcell.

Par exemple du mets J1 en linkedcell, tu masques la colonne J et en I1 tu mets la formule

Rechercher des sujets similaires à "preformate texte vba mail outlook2016"