Sub Mail() 'envoi mail
Dim OutObj As Object, OutMail As Object
Dim sPath As String, sNomFic As String
Dim sAdrmail As String, strSujet As String, strBody As String
Set OutObj = CreateObject("outlook.application") 'lance outlook
Set OutMail = OutObj.CreateItem(0)
sAdrmail = "Raf26@toto.com" 'adresse destinataire
SAdrCC = "moimeme@hotmail.com' 'adresse CC"
strSujet = "juste un coucou" 'sujet du mail
strBody = "<p>"
strBody = strBody & arrangetext("Bonjour ", RGB(255, 0, 255), 15, , True, True, True)
strBody = strBody & arrangetext("Raf26 ", "3", 28, , True, , True) & "<br/>"
strBody = strBody & arrangetext("comment va tu aujourd'hui", "orange", , "Arial") & "<br/>"
strBody = strBody & "tu t'éclate bien sur "
strBody = strBody & arrangetext("EXCELDOWNLOAD", "green", 30, "Algerian", True)
strBody = strBody & "</p>"
With OutMail
.Display 'affiche le mail sans l'envoyer sinon .send
.To = sAdrmail
.CC = SAdrCC
.Subject = strSujet
.HTMLBody = strBody
End With
Set OutMail = Nothing
Set OutObj = Nothing
End Sub
Function arrangetext(txt, Optional couleur As Variant = "", Optional fontsiz As Long = 0, Optional fontName As String = "calibri", Optional bolder As Boolean = False, Optional italique As Boolean = False, Optional underligne As Boolean = False, Optional barré As Boolean = False)
Dim Fc As Object
With CreateObject("htmlfile")
Set Fc = .createelement("FONT")
If IsNumeric(couleur) Then
If couleur <= 56 Then couleur = HtmlColor(ThisWorkbook.Colors(couleur)) Else couleur = HtmlColor(couleur)
End If
If couleur <> "" Then Fc.Color = couleur
If fontsiz > 0 Then Fc.Style.FontSize = fontsiz & "px"
If fontName <> "calibri" Then Fc.face = fontName
If barré Then txt = "<strike>" & txt & "</strike>"
If underligne Then txt = "<u>" & txt & "</u>"
If italique Then txt = "<em>" & txt & "</em>"
If bolder Then txt = "<strong>" & txt & "</strong>"
Fc.innerhtml = txt
If Not IsNull(Fc.getattribute("size")) Then Fc.removeAttribute ("size")
arrangetext = Fc.outerhtml
End With
End Function
Function HtmlColor(x) As String
c = Right("000000" & Hex(x), 6)
HtmlColor = "#" & Mid(c, 5, 2) & Mid(c, 3, 2) & Mid(c, 1, 2)
End Function