Envoi mail automatique avec thunderbird et sauvegarde du jour

bonjour

je bloque sur le fait de pouvoir faire partir tous les jours un mail avec la sauvegarde daté du jour.

j’ai réussi a faire une macro pour la sauvegarde automatique avec date et l’envoi du mail…

Par contre je ne trouve pas comment faire pour que la pièce jointe soit la dernière généré dans mon dossier de sauvegarde.

voici mes macros.

Private Sub Workbook_Deactivate()

ChDrive « C:\Users\OLIVIER\Documents\rapport »

ChDir « C:\Users\OLIVIER\Documents\rapport »

SaveFileName = CurDir & « » & « rapport journalier C.A.B » & « _ » & Format(Date, « dd-mm-yyyy ») & « .xlsm »

ActiveWorkbook.SaveAs Filename:=SaveFileName, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

End Sub

et la deuxième :

Private Sub CommandButton1_Click()

Dim destinataire, sujet, fichierjoint As String

destinataire = « moi@ »

sujet = « essai! »

body = « Rapport Journalier C.A.B ? »

fichierjoint = « C:\Users\OLIVIER\Documents\rapport\rapport journalier C.A.B_20-06-2020.xlsm »

strcommand = « C:\Program Files\Mozilla Thunderbird\thunderbird »

strcommand = strcommand & " -compose " & « to=’ » & destinataire & « ’ »

strcommand = strcommand & « , » & « subject= » & sujet & « , »

strcommand = strcommand & « body= » & body

strcommand = strcommand & « , » & « attachment=file:/// » & fichierjoint

MsgBox strcommand

Call Shell(strcommand, vbNormalFocus)

End Sub

merci de votre aide.

olivier

Bonjour et

Encadre ton code avec </> pour le rendre lisible

essaie ceci

strcommand = strcommand & "," & "attachment=" & fichierjoint

Merci mais malheureusement cela ne fonctionne pas.

j'ai une nouvelle macro a l'essai

<Private Sub CommandButton1_Click()

Dim destinataire, sujet, fichierjoint As String

Chemin = " C:\Users\OLIVIER\Documents\rapport"

Fichier = Dir(Chemin & "*.xlsm")

dateretenue = "01-01-1900"

Do While Fichier <> ""

dateenregistrement = Right(Split(Fichier, ".xlsm")(0), 10)

If IsDate(dateenregistrement) Then

If CDate(dateenregistrement) > CDate(dateretenue) Then

dateretenue = dateenregistrement

derfichier = Fichier

End If

End If

Fichier = Dir

Loop

destinataire = "moi@"

sujet = "essai!"

body = derfichier

fichierjoint = "C:\Users\OLIVIER\Documents\rapport" & derfichier

strcommand = "C:\Program Files\Mozilla Thunderbird\thunderbird"

strcommand = strcommand & " -compose " & "to=’" & destinataire & "’"

strcommand = strcommand & "," & "subject=" & sujet & ","

strcommand = strcommand & "body=" & body

strcommand = strcommand & "," & "attachment=file:///" & fichierjoint

MsgBox strcommand

Call Shell(strcommand, vbNormalFocus)>

mais j'ai qlqs soucis avec..

merci de ton aide

Encadre ton code avec </> pour le rendre lisible

et ...

Merci mais malheureusement cela ne fonctionne pas.

ce n'est pas ce que j'ai préconisé !

strcommand = strcommand & "," & "attachment=file:///" & fichierjoint

pourquoi file:///

Essaie aussi

strcommand = strcommand & "," & "attachment=""" & fichierjoint & """"

Sinon, voici un exemple avec pièce jointe qui fonctionne ...

Rechercher des sujets similaires à "envoi mail automatique thunderbird sauvegarde jour"