Sub EnvoiMail()
Dim MsgPerso As String, Sujet As String, nF as string
' balise </B> pour mettre en gras <B>
' balise <BR> pour aller à la ligne
Sujet = "Coucou c'est le sujet du Mail"
MsgPerso = "Bonjour," & "<BR>"
MsgPerso = MsgPerso & "Je te prie de trouver ci-joint le fichier " & "</B>" & "excel" & "</B>" & " que je t'avais dit que j'allais t'envoyer, l'autre fois à la machine à café."
MsgPerso = MsgPerso & "Cordialement," & "<BR>" & "MickeyBoy" & "<BR>" & "" & "<BR>" & "" & "<BR>"
MsgPerso = MsgPerso & "<BR>" & "<BR>"
nF = Left$(ActiveWorkbook.FullName, Len(ActiveWorkbook.FullName) - 4)
ActiveWorkbook.SaveCopyAs nF & "_.xls"
With CreateObject("CDO.Message")
.From = "toto@FAI.fr" 'Adresse expéditeur
.To = "tata@hotmail.com" 'Adresse Destinataire
.cc =
.Subject = Sujet
.HTMLBody = MsgPerso
.AddAttachment (nF & "_.xls")
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.club-internet.fr" 'à adapter selon FAI
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Configuration.Fields.Update
On Error Resume Next
.Send
If Err Then MsgBox "Le message n'a pas pu être expédié."
On Error GoTo 0
End With
Kill nF & "_.xls" 'Effacement du fichier créé et envoyé par mail.
End Sub