Generer un mail avec piece jointe thunderbird
Bonjour,
mon code ci-après refuse de fonctionner : aucune pièce jointe n'apparait dans le mail Thunderbird.
Qu'en pensez-vous ?
PS : il faut sélectionner un fournisseur dans la liste du tableau "Fournisseurs" et cliquer sur "Envoyer par mail".
Private Sub Imp_partielle_Click()
Dim LaDate$, Nom$, Rep$, Fichier$, Chemin$
LaDate = Format(Now, "yyyy_mm_dd_")
Nom = ActiveCell.Value
Rep = Workbooks(ActiveWorkbook.Name).Path
Fichier = "\" & LaDate & "_" & Nom & ".pdf"
Chemin = Rep & Fichier
MsgBox (Chemin)
Sheets("PARTIELLE").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
Rep & Fichier, Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
From:=1, To:=1, OpenAfterPublish:=True
Dim destinataire, sujet As String
If Nom = "DABSTART" Then destinataire = "dabstart@gmail.com"
If Nom = "ENDOTECH" Then destinataire = "endotech@gmail.com"
sujet = "COMMANDE MATERIEL SCM ETCHARRY CORBIN"
body = "Bonjour, veuillez trouver ci-joint une commande de matériel."
strcommand = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird"
strcommand = strcommand & " -compose " & "mailto:" & destinataire & "?"
strcommand = strcommand & "&" & "subject=" & sujet & "&"
strcommand = strcommand & "body=" & body & "&"
strcommand = strcommand & "," & "attachment=file:///" & Chemin
MsgBox (strcommand)
Call Shell(strcommand, vbNormalFocus)
End Sub
Bonjour,
As-tu regardé au bas dans "Sujets similaires" ?
ric
Bonjour ric,
effectivement j'ai fouillé dans les sujets similaires.
Ne trouvant pas d'explication au problème rencontré, j'ai opté pour une autre méthode, qui fonctionne :
Private Sub Imp_partielle_Click()
Dim LaDate$, Nom$, Rep$, Fichier$, Chemin$
LaDate = Format(Now, "yyyy_mm_dd_")
Nom = ActiveCell.Value
Rep = Workbooks(ActiveWorkbook.Name).Path
Fichier = "\" & LaDate & "_" & Nom & ".pdf"
Chemin = Rep & Fichier
Sheets("PARTIELLE").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
Rep & Fichier, Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
From:=1, To:=1, OpenAfterPublish:=False
Dim destinataire, sujet As String
If Nom = "DABSTART" Then destinataire = "dabstart@gmail.com"
If Nom = "ENDOTECH" Then destinataire = "endotech@gmail.com"
sujet = "COMMANDE MATERIEL SCM ETCHARRY CORBIN"
body = "Bonjour.%0a%0aMerci de bien vouloir traiter la commande disponible en pièce jointe.%0a%0aCordialement."
Mail = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe"
monCourriel = " -compose " & "to=" & destinataire & "," & "subject=" & sujet & "," & "body=" & body & "," & "attachment=" & Chemin
Shell Mail & monCourriel, vbNormalFocus
SendKeys "^+{ENTER}", True
End Sub
Ceci dit, j'aurai bien aimé savoir pourquoi ma formule précédente ne fonctionne pas... et surtout je pense qu'il s'agit certainement d'une infime et grossière erreur !
Si quelqu'un trouve la réponse, je suis preneur malgré tout !
Merci à tous.
Bonjour,
Après sujet, il y avait ( & "&" ) de trop, ainsi qu'après body.
Note : body le corps du message et body l'objet, c'est un peu mêlant.
Ajouter en première ligne "Option Explicit" afin d'obliger la déclaration des variables.
La virgule est le séparateur de champs ... la virgule après Bonjour entrait en conflit.
Donc, ceci fonctionne ...
Option Explicit
Private Sub Imp_partielle_Click()
Dim destinataire As String, sujet As String
Dim LaDate$, Nom$, Rep$, Fichier$, Chemin$
Dim LeBody$
Dim strcommand$
LaDate = Format(Now, "yyyy_mm_dd_")
Nom = ActiveCell.Value
Rep = Workbooks(ActiveWorkbook.Name).Path
Fichier = "\" & LaDate & "_" & Nom & ".pdf"
Chemin = Rep & Fichier
Sheets("PARTIELLE").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
Rep & Fichier, Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, From:=1, To:=1, OpenAfterPublish:=False
If Nom = "DABSTART" Then destinataire = "dabstart@gmail.com"
If Nom = "ENDOTECH" Then destinataire = "endotech@gmail.com"
sujet = "COMMANDE MATERIEL SCM ETCHARRY CORBIN"
LeBody = "Bonjour! Veuillez trouver ci-joint une commande de matériel."
strcommand = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe"
strcommand = strcommand & " -compose " & "to=" & destinataire & ","
strcommand = strcommand & "&" & ",subject=" & sujet
strcommand = strcommand & ",body=" & LeBody
strcommand = strcommand & Chr(10) & ",attachment=" & Chemin
Call Shell(strcommand, vbNormalFocus)
End Sub
ric
Ceci dit, j'aurai bien aimé savoir pourquoi ma formule précédente ne fonctionne pas... et surtout je pense qu'il s'agit certainement d'une infime et grossière erreur !
Bonjour,
je pense que l'erreur est ici :
strcommand = strcommand & "," & "attachment=file:///" & Chemin
à remplacer par (ne pas mettre file:///)
strcommand = strcommand & "," & "attachment=" & Chemin
Merci à tous d'avoir pris le temps de répondre à cette problématique !!