Envoi mail avec Thunderbird totalement automatique

Bonjour le forum,

Je me pose une question à laquelle il m'est impossible de trouver une réponse, même après avoir fouillé les moindres recoins du web.

J'ai petit outil de mailing développé en VBA qui fonctionne avec Mozilla Thunderbird. (Logiciel que l'on doit utiliser au boulot).

Est-il possible de complétement automatiser l'envoi ? C'est à dire, envoyer le mail en arrière plan sans qu'aucune fenêtre ne s'ouvre ?

Un peu comme avec Outlook, (avec la méthode .send au lieu de .display)

J'ai trouvé un début de solution en plaçant

Application.Wait (Now + TimeValue("0:00:03"))
    SendKeys "^{ENTER}", True

ce qui me permet d'envoyer le mail automatiquement, mais je ne veux pas que les fenêtres s'ouvrent, j'aimerai que tout se fasse en arrière plan.

Voici le code que j'utilise :

Sub envoi_mail()
Application.ScreenUpdating = False

Dim destinataire As String
Dim sujet As String
Dim body As String
Dim i As Integer
Dim PJ As String

With Sheets("Mailing")
    For i = 7 To .[L65536].End(xlUp).Row 

    destinataire = .Cells(i, "L")

sujet = Range("B7")
body = Range("B10")

strcommand = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe"
strcommand = strcommand & " -compose " & "to='" & destinataire & "'"
strcommand = strcommand & "," & "subject=" & sujet & ","
strcommand = strcommand & "body='" & Chr(34) & body & Chr(34) & "'"
strcommand = strcommand & "," & "format='" & 1 & "'"

    If Range("L2") <> 0 Then
        PJ = Range("L2")
strcommand = strcommand & "," & "attachment='file:///" & PJ & "'"
Else
End If
Call Shell(strcommand, vbNormalFocus)

Application.Wait (Now + TimeValue("0:00:03"))
    SendKeys "^{ENTER}", True
Next i

End With
Application.ScreenUpdating = True

End Sub

Voila si vous avez un début de réponse, ça serait super !

Merci bien

Bonjour Lucas54000 le forum

je n'ai pas thunderbird mais tu peux tester ceci STP et me redire

a+

Papou

Sub envoi_mail()
    Application.ScreenUpdating = False
    Dim destinataire$, sujet$, body$, i&, PJ$
    With Sheets("Mailing")
        For i = 7 To .[L65536].End(xlUp).Row
            destinataire = .Cells(i, "L")
            sujet = Range("B7")
            body = Range("B10")
            strcommand = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe"
            strcommand = strcommand & " -compose " & "to='" & destinataire & "'"
            strcommand = strcommand & "," & "subject=" & sujet & ","
            strcommand = strcommand & "body='" & Chr(34) & body & Chr(34) & "'"
            strcommand = strcommand & "," & "format='" & 1 & "'"
            If Range("L2") <> 0 Then
                PJ = Range("L2")
                strcommand = strcommand & "," & "attachment='file:///" & PJ & "'"
            Else
            End If
            Call Shell(strcommand, vbNormalNoFocus)
            Application.Wait (Now + TimeValue("0:00:03"))
            SendKeys "^{ENTER}", True
        Next i
    End With
    Application.ScreenUpdating = True
End Sub

Bonjour Papou,

Je te remercie pour cette réponse.

Mais c'est exactement le même code que le mien ??

Je vais tester quand même,

Merci bien

Re Bonjour Lucas54000 le forum

c'est exactement le même code que le mien ??

si tu le penses tu as raison, mais je serais de toi je regarderais et je testerais avant de dire non

je ne peux pas te garantir que cela marchera puisque je ne peux pas le tester personnellement, mais je pense que la modif va fonctionner

a+

Papou

Re-bonjour Papou,

alors j'ai testé mais sans succès.

Le mail est bien envoyé automatiquement mais la fenêtre s'ouvre quand même.

Un grand merci quand même pour ton aide,

Lucas

Re Lucas54000 le forum

Je vais chercher encore mais normalement il n’aurait Pas du prendre le focus

C’est le bazar quand on ne peut pas tester!!!

Bonne journée

Papou

Re Lucas54000 le forum

essaye voir cela

a+

Papou

Sub envoi_mail()
    Application.ScreenUpdating = False
    Dim destinataire$, sujet$, body$, i&, PJ$
    With Sheets("Mailing")
        For i = 7 To .[L65536].End(xlUp).Row
            destinataire = .Cells(i, "L")
            sujet = Range("B7")
            body = Range("B10")
            strcommand = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe"
            strcommand = strcommand & " -compose " & "to='" & destinataire & "'"
            strcommand = strcommand & "," & "subject=" & sujet & ","
            strcommand = strcommand & "body='" & Chr(34) & body & Chr(34) & "'"
            strcommand = strcommand & "," & "format='" & 1 & "'"
            If Range("L2") <> 0 Then
                PJ = Range("L2")
                strcommand = strcommand & "," & "attachment='file:///" & PJ & "'"
            Else
            End If
            Call Shell(strcommand, vbMinimizedNoFocus)
            Application.Wait (Now + TimeValue("0:00:02"))
            SendKeys "^{ENTER}", True
        Next i
    End With
    Application.ScreenUpdating = True
End Sub

Merci encore pour ton aide Papou.

Malheureusement j'ai toujours la fenêtre qui s'ouvre, le mail qui s'envoie, et la fenêtre qui se referme. C'est curieux.

J'ai également testé avec vbHide, sans succès.

Ce n'est peut-être tout simplement pas possible avec Thunderbird.

En tous cas un grand merci d'avoir essayé de m'aider, sans pouvoir tester de surcroît !

Lucas

Re Lucas54000 le forum

Je vais encore chercher je pense que c’est possible

A plus

Papou

Rechercher des sujets similaires à "envoi mail thunderbird totalement automatique"