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
| Sub ExempleNewMail()
Dim appOutlook As Outlook.Application
Set appOutlook = Outlook.Application
Dim Message As Outlook.MailItem
Dim objRecipient As Outlook.Recipient
Set Message = appOutlook.CreateItem(olMailItem)
With Message
.subject = "Mon Objet"
'Soit on ajoute un Corps en TEXTE BRUT
.BodyFormat = olFormatPlain
.Body = "Voici le coprs du Mail" & vbCr & " A la ligne"
'Soit on ajoute un Corps en HTML
.BodyFormat = olFormatHTML
.HTMLBody = "<html><body> <font face=""arial""><p>Bonjour,</p><p>Ceci est un exemple de Message HTML</p><p>Il faut utiliser des balises HTML pour formater le texte.</p><p>En <strong>gras</strong>, <em>Italic</em>, <u>Souligné</u></p><BR><p>Je suis passé à la ligne</p><p>Voici un lien hypertexte.</p>" & _
"<a href=""mailto:Joe.User@MyCompany.com"">Joe User</a></font></body></html>"
'Ajout d'un destinataire principal
Set objRecipient = .Recipients.add("toto@toto.com")
objRecipient.Type = olTo 'olBCC, olCC, olOriginator ou olTo.
objRecipient.Resolve
'Ajout d'un destinataire en copie
Set objRecipient = .Recipients.add("titi@toto.com")
objRecipient.Type = olCC 'olBCC, olCC, olOriginator ou olTo.
objRecipient.Resolve
'
'Ajout d 'une PJ
Dim MaPj
MaPj = "c:\temp\monPDF.PDF"
'on verifie d'abord qu'elle existe.
If Dir(MaPj) <> "" Then
.Attachments.add MaPj
End If
'ajout ar lecture
.ReadReceiptRequested = True
'Soit je l'affiche
.Display
'Soit je l'envoi
'.Send
End With
End Sub |
Partager