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