Re : VBA Envoi de mail avec Thunderbird et caractère avec accents
Bonjour,
Voici la solution que j'ai trouvé sur un autre forum :
Private Sub MailECOTOUR_Click()
Dim destinataire, sujet, sujet1 As String
destinataire = InputBox("E-mail du destinataire")
sujet = "Votre projet de voyage Ecotour \ Dossier N° "
sujet1 = InputBox("N° de dossier")
text1 = ConverAcute(Range("A3")) & "<br><br>"
text2 = ConverAcute(Range("A7")) & "<br><br>"
text3 = ConverAcute(Range("A9")) & "<br>"
text4 = ConverAcute(Range("A11")) & "<br><br>"
text5 = ConverAcute(Range("A13")) & "<br>"
text6 = ConverAcute(Range("A15")) & "<br><br>"
text7 = ConverAcute(Range("A17")) & "<br>"
text8 = ConverAcute(Range("B2")) & "," & "<br>"
text9 = ConverAcute(Range("A18")) & " " & ConverAcute(Range("E18"))
body = text1 & text2 & text3 & text4 & text5 & text6 & text7 & text8 & text9
strcommand = "C:\Program Files\Mozilla Thunderbird\thunderbird"
strcommand = strcommand & " -compose " & "to='" & destinataire & "'"
strcommand = strcommand & "," & "subject=" & sujet & sujet1 & ","
strcommand = strcommand & "body='" & body & "'"
MsgBox strcommand
Call Shell(strcommand, vbNormalFocus)
End Sub
Sub test()
txt = ConverAcute("éàè")
End Sub
Public Function ConverAcute(txt) As String
ConverAcute = Trim("" & txt)
ConverAcute = Replace(ConverAcute, "Á", "Á", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "á", "á", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "À", "À", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "à", "à", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Â", "Â", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "â", "â", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Ä", "Ä", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "ä", "ä", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "É", "É", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "é", "é", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "È", "È", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "è", "è", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Ê", "ê", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "ê", "Ê", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Ë", "Ë", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "ë", "¨", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Í", "Í", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "í", "í", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Ì", "Ì", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "ì", "ì", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Î", "Î", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "î", "î", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Ï", "Ï", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "ï", "ï", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Ó", "Ó", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "ó", "Ó", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Ò", "Ò", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "ò", "ò", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Ô", "Ô", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "ô", "ô", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Ö", "Ö", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "ö", "ö", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Ú", "Ú", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "ú", "ú", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Ù", "Ù", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "ù", "ù", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Û", "Û", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "û", "û", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Ü", "Ü", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "ü", "ü", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "Ý", "Ý", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "ý", "ý", 1, -1, vbBinaryCompare)
ConverAcute = Replace(ConverAcute, "ÿ", "ÿ", 1, -1, vbBinaryCompare)
End Function