voila un exemple de Formulaire en HTML Application HTA pour envoyer un e-mail avec pièce-jointe par deux méthodes:
1-Via le serveur Gmail en utilisant l'authentification SMTP et SSL de ce dernier
2-Via Votre Serveur SMTP sans authentification
NB: Pour la 2ème méthode on peut l'utiliser sans login et sans mot de passe si on est sous le même Domaine et on peut aussi l'utiliser aussi si on est devant un Proxy , il suffit juste remplacer le contenu du champ SMTP "smtp.serveur.com"par son adresse IP par exemple si votre Proxy a comme adresse IP 172.16.0.1 ou bien 192.168.1.1
( A vérifier chez vous )

Donc Copier/Coller ce code et enregister-le sous Mail.hta par exemple
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<html> 
<head> 
<HTA:APPLICATION 
    ICON="icon.ico"
    APPLICATIONNAME = "SMTP Mail Client" 
    BORDER="dialog"
    BORDERSTYLE="complex"
    CONTEXTMENU="no"
    SYSMENU="yes"
    MAXIMIZEBUTTON="no"
    SCROLL="no" 
>
<title>SMTP Mail Client © Hackoo</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<style>
    body{
        background-color: lightblue;
    }
    label,.btn{
        font-weight: bold;
    }
</style>
<script language="VBScript">
Const cdoSendUsingPickup = 1 
Const cdoSendUsingPort = 2 'Must use this to use Delivery Notification
Const cdoAnonymous = 0
Const cdoBasic = 1 ' clear text
Const cdoNTLM = 2 'NTLM
'Delivery Status Notifications
Const cdoDSNDefault = 0 'None
Const cdoDSNNever = 1 'None
Const cdoDSNFailure = 2 'Failure
Const cdoDSNSuccess = 4 'Success
Const cdoDSNDelay = 8 'Delay
Const cdoDSNSuccessFailOrDelay = 14 'Success, failure or delay
messageSSLHTML = "<center><font size=4 FACE=Comic sans MS style=font-weight:bold Color=red Color=red>Ceci est un exemple de message en HTML.<br>Il a été envoyé en utilisant l'authentification SMTP et SSL.<br><br>"
Signature = "<center><font size=10 FACE=Comic sans MS style=font-weight:bold Color=red><br>©<br><img src=http://photomaniak.com/upload/out.php/i1102064_IDNlogo.gif>" 
 
Sub ViaGmail
Dim f1
f1 = file.Value
Login = InputBox ("Donner Votre adresse email  !", "ADRESSE GMAIL DU EXPEDITEUR", "moi@gmail.com") 
Password = InputBox ("Donner Votre Mot de passe email  !", "VOTRE MOT DE PASSE GMAIL", "")
GmailBox=MsgBox ("Envoi avec ces Options:" & vbCrLf &"Expéditeur :"& Login & vbCrLf & "Destinataire : "& txtTo.Value &  vbCrLf & "Sujet :" & txtSubject.Value & vbCrLf & "FileAttach1 :"& f1 ,vbYesNo+64,"Message Options")
    If GmailBox = vbYes Then 
	if  SendGmailSSL(Login,Password, txtTo.Value, txtSubject.Value, txtBody.value+messageSSLHTML+Signature,f1)= 0  Then
 
    MsgBox "Le Mail a été envoyé avec succès !",vbInformation ,"Information"
    Else
 
    MsgBox "Echec d'envoi du Mail !",vbExclamation ,"Information"
    End If
    End If
End Sub
 
Function SendGmailSSL( sFrom, sPassword, sTO ,sSubject, sBody, sFilePath1)
 
    Set objMessage = CreateObject("CDO.Message") 
    objMessage.Subject = sSubject 
    objMessage.From = sFrom
    objMessage.To = sTO
    objMessage.HTMLBody = sBody 
    If sFilePath1 <> "" Then
        objMessage.AddAttachment sFilePath1   
    End If
 
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" 
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = sFrom
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = sPassword
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    objMessage.Configuration.Fields.Update
 
    On Error Resume Next
    objMessage.Send
    SendGmailSSL = Err.Number
    If Err.Number <> 0  Then
        MsgBox Err.Description, 16, "SendGmailSSL Erreur"
    End If
 
End Function
 
 
    Sub window_onload()
        CenterWindow 415, 600
    End Sub
 
    Sub CenterWindow(x,y)
        window.resizeTo x, y
        iLeft = window.screen.availWidth/2 - x/2
        itop = window.screen.availHeight/2 - y/2
        window.moveTo ileft, itop
    End Sub
 
    Sub SendMail()
        SendMailMessage txtFrom.Value, txtTo.Value, txtSubject.Value, txtBody.value ,txtSMTPSERVER.Value, file.Value      
    End Sub
 
    Sub SendMailMessage( sFrom, sTo, sSubject, sBody, SMTPSERVER, File)
        MsgBox "Envoi du Mail avec ces options:"& vbCrLf &"Expéditeur: "& sFrom & vbCrLf & "To: " & sTo & vbCrLf &"Sujet: " & sSubject & vbCrLf &"Text Message: " & sBody & vbCrLf & "SMTP SERVER: " & SMTPSERVER & vbCrLf & "Piéce-jointe: " & File,64,"Send Email"
        messageHTML="<center><font size=4 FACE=Comic sans MS style=font-weight:bold Color=red>Ceci est un exemple de message avec Signature en HTML <br> envoyé par Hackoo !" 
        File = document.getElementById("file").Value 
 
        Set msg = CreateObject("CDO.Message") 
        With msg
            .From = sFrom
            .To = sTo 
            .Subject = sSubject
            .TextBody = sBody 
            .HTMLBody=sBody & messageHTML & Signature 
            .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
            .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPSERVER 
            .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
            If File <> "" Then
               .AddAttachment File  'Ajout de la piéce-jointe
            End If  
            .Configuration.Fields.Update 
            On Error Resume Next
            .Send
            If Err.Number <>0 Then 
                MsgBox Err.Description,16,"Error Sending Mail"
            Else 
                MsgBox "Le Mail a été envoyé avec succès !",64,"Information" 
            End If
 
        End With
 
    End Sub
</script> 
</head> 
 
<body> 
 
    <label for="Expéditeur" style="width: 120; textalign: right;">Expéditeur:</label><input type="text" id="txtFrom" name="Expéditeur" value="Expéditeur@gmail.com"><br /> 
    <label for="to" style="width: 120; textalign: right;">Destinataire:</label><input type="text" id="txtTo" name="to" value="Destinataire@gmail.com"><br />
    <label for="subject" style="width: 120; textalign: right;">Sujet:</label><input type="text" id="txtSubject" name="sujet" value="Sujet"><br />
    <label for="txtSMTPSERVER" style="width: 120; textalign: right;">SMTP:</label><input type="text" id="txtSMTPSERVER" name="txtSMTPSERVER" value="smtp.serveur.com"><br />
    <label for="file">Pièce-Jointe :</label><br />
    <input type="file" name="file" id="file" /><br>
    <label>Message:</label><br />
    <textarea id="txtBody" rows="20" cols="45"></textarea><br><br>
    <center>
    <input class="btn" type="button" value="Envoyer Via Gmail" onClick="ViaGmail">
    <input class="btn" type="button" value="Envoyer Via SMTP" onClick="SendMail">
</body> 
</html>
J'attends vos tests et vos commentaires