Bonjour à vous,

Je voudrais envoyer mon fichier par mail!

Le code ci dessous montre une erreur "le transport à échoué lors de la connexion au serveur"

Voici le code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Private Sub CommandButton1_Click()
 
 
  Dim iMsg As Object, iConf As Object, flds As Object, cDoMessage As Object
Dim Sourcewb As Workbook
Dim Destwb As Workbook
Dim Temp As String
Dim Fichier As String
 
Set iMsg = CreateObject("cdo.message")
Set iConf = CreateObject("cdo.configuration")
 
 
Set Sourcewb = ActiveWorkbook
    Fichier = ThisWorkbook.Path & Application.PathSeparator & "Classeur.xlsm"
 
    Sourcewb.SaveCopyAs Fichier
 
Set flds = iConf.Fields
With flds
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    'remplacez "smtp.nomserveur.fr" par le nom de serveur de votre FAI :
    'http://outlook.developpez.com/faq/index.php?page=Configuration#Paras_FAI
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.orange.fr "
    .Update
End With
 
With iMsg
    Set .Configuration = iConf
    .To = "xxxx@hotmail.fr"
    .From = "ttttt@orange.fr"
    .Subject = "Le sujet du message"
    .HTMLBody = "Ceci est un essai ..."
    .AddAttachment Fichier
    .Send
End With
 Set cDoMessage = Nothing
    Kill Fichier
    End Sub
J'avais essayé sans le fichier et ça fonctionnait!

Auriez-vous une solution à me proposer?

Merci