Joindre un fichier à un courriel

GillesC

XLDnaute Occasionnel
Bonjour le forum,
j'ai parcouru des tonnes de messages sur ce sujet sans trouver mon bonheur, et je m'y perd!

J'ai donc une macro simple qui génère un courriel (avec Mozilla Thunderbird) :

Code:
Sub Mail_TDB_Prod()
Dim Subj As String
Dim Ligne1 As String
Dim Ligne2 As String
Dim Ligne3 As String
Dim URLto As String

Subj = "Tableau de bord Production"
Ligne1 = "Bonjour,"
Ligne2 = "Vous trouverez ci-joint la dernière version du tableau de bord Production."
Ligne3 = "Cordialement"

URLto = "mailto:toto@tata.fr" & "?subject=" & Subj & "&body=" & "&body=" & Chr(10) & Ligne1 & Chr(10) & "&body=" & Chr(10) & Ligne2 & "&body=" & Chr(10) & Ligne3
ActiveWorkbook.FollowHyperlink Address:=URLto

End Sub

Le courriel se génère bien, mais je ne sais pas comment faire pour joindre le fichier C:/toto.xls

Merci de votre aide
 

tototiti2008

XLDnaute Barbatruc
Re : Joindre un fichier à un courriel

Bonjour GillesC,

à ma connaissance, avec mailto tu ne peux pas joindre de fichier...
Donc soit envisager un code spécifique qui utilise ton client Thunderbird (je ne connais pas mais ça doit exister, je pense), soit voir pour envoyer des mails avec CDO (je crois qu'il y a pas mal de fils/FAQ sur le sujet)
 

jn.steph

XLDnaute Nouveau
Re : Joindre un fichier à un courriel

En fouillant sur le forum, je retombe sur cette discussion pour laquelle il n'y a pas de réponse.
J’aimerais vraiment savoir comment faire également pour joindre un fichier sous Outlook 2007 ?!!
Merci pour vos lumières
JN
 

MJ13

XLDnaute Barbatruc
Re : Joindre un fichier à un courriel

Bonjour à tous

Issu d'un lien de Kiki et de Ron :):

Ce lien n'existe plus

Code:
Sub Mail_Workbook_1()
' Works in Excel 2000, Excel 2002, Excel 2003, Excel 2007, Excel 2010, Outlook 2000, Outlook 2002, Outlook 2003, Outlook 2007, Outlook 2010.
' This example sends the last saved version of the Activeworkbook object .
    Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
   ' Change the mail address and subject in the macro before you run it.
    With OutMail
        .To = "test@test.fr"
        .CC = ""
        .BCC = ""
        .Subject = "This is the Subject line"
        .Body = "Hello World!"
        .Attachments.Add ActiveWorkbook.FullName
        ' You can add other files by uncommenting the following line.
        '.Attachments.Add ("C:\test.txt")
        ' In place of the following statement, you can use ".Display" to
        ' display the mail.
        .Send   
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub
 

DoubleZero

XLDnaute Barbatruc
Re : Joindre un fichier à un courriel

Bonjour à toutes et à tous,

La macro insérée au fichier ci-après permet l’envoi d’un courriel avec pièce jointe.

Je l’ai, à la fois modestement et rapidement, testée (sans parvenir à modifier certains points :confused:).

Toutefois, sous Windows 7 et Excel 2007, son fonctionnement est OK :) .

Bon courage.
 

Pièces jointes

  • vbfrance_ENVOI-AUTOMATIQUE-MAIL-AVEC-PIECE-JOINTE-VBA-EXCEL___Page.zip
    45.3 KB · Affichages: 76

Discussions similaires

Membres actuellement en ligne

Statistiques des forums

Discussions
312 370
Messages
2 087 693
Membres
103 641
dernier inscrit
anouarkecita2