Bonjour,

Je cherche à créer un formulaire, dans lequel se trouve un champ permettant à l'utilisateur d'envoyer une image. Le formulaire doit ensuite être envoyé par mail.

Le code du formulaire :

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
Sub DisplayForm()  
Displayerrors 
  response.write "<div class='formu'>"
  response.write "<form name='creation' method=post action=createurs.asp accept='image/PSD,image/EPS,image.AI,image/PDF'>"
  response.write "  <div class='fgauche'>"
  response.write "    <label for='nom'>Votre nom : </label><br>"
  response.write "    <input type='text' name='nom' id='nom'/>"
  response.write "  </div>"
  response.write "  <div class='fdroite'>"
  response.write "    <label for='prenom'>Votre prénom : </label><br>"
  response.write "    <input type='text' name='prenom' id='prenom'/>"
  response.write "  </div>"
  response.write "  <div class='fgauche'>"
  response.write "    <label for='mail'>Votre e-mail : </label><br>"
  response.write "    <input type='text' name='mail' id='mail'/>"
  response.write "  </div>"
  response.write "  <div class='fdroite'>"
  response.write "    <label for='tel'>Votre numéro de téléphone : </label><br>"
  response.write "    <input type='text' name='tel' id='tel'/>"
  response.write "  </div>"
  response.write "  <div class='fgauche'>"
  response.write "    <label for='image'>Fichier image (.PSD, .EPS, .AI, .PDF) : </label><br>"
  response.write "    <input type='file' name='image' id='image'/>"
  response.write "  </div>"
  response.write "  <div class='fgauche'>"
  response.write "    <label for='comm'>Commentaires : </label><br>"
  response.write "    <textarea rows=8 cols=50 name='comm' id='comm'>"
  response.write "    </textarea>"
  response.write "  </div>"
  response.write "  <div class='bouton'><input type=image  name=action src='images/btn_envoyer.gif'/></div>"
  response.write "</form>"
  response.write "</div>"
end sub
Ensuite pour envoyer le mail je dispose de 2 autres fonctions :

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
Sub SendMailToMerchant (isubject)
dim acount
dim my_attachment, htmlformat
htmlformat="Text"
my_attachment=request.Form("image")
mailtype=getconfig("xemailtype")
my_from=strlastname
my_fromaddress=stremail
my_toaddress=getconfig("xemail")
my_to=getconfig("xemailname")
my_system=getconfig("xemailsystem")
my_subject=isubject  
Body=""
body=body & shopdateformat(date(),getconfig("xdateformat")) & " " & time()& vbcrlf & vbcrlf
Body=Body & Strfirstname & " " & strLastname & vbcrlf
Body=body & stremail & vbcrlf
if strcompany<>"" then
  Body=body &  getlang("LangCustcompany") & " " & strcompany & vbcrlf
end if
body=body & vbcrlf
body=body & strcomment  
acount=1
ExecuteMail mailtype,My_from,my_fromaddress,my_to,my_toaddress,my_subject,body,htmlformat,my_attachment,acount
If getconfig("xdebug")="Yes" then
  debugwrite "Mailing to: " & my_to & "(" & my_toaddress  & ") from " & strlastname & " " & stremail
end if
end sub
 
sub ExecuteMail(mailtype,My_from,my_fromaddress,my_to,my_toaddress,my_subject,body,emailformat,Orderattachments, Orderattachmentcount)
dim mailer
dim mailerror
dim htmlformat
dim i
my_system=getconfig("xemailsystem")
htmlformat=ucase(emailformat)
 
If ucase(mailtype)="CDONTS" Then
    Set Mailer = Server.CreateObject("CDONTS.NewMail")
    if err.number <> 0 then
        mailerror = getlang("langmailerror") & " " & mailtype
        mailerror = mailerror & "Error N° : " & err.number & " - Error description : " & err.Description
        HandleMailError mailerror 
        'exit sub
    end if
    Mailer.To = my_toaddress
    Mailer.From = my_from & " <" & my_fromaddress & ">"
    Mailer.Subject = my_subject
    Mailer.Body = body
    If htmlformat="HTML" then
        Mailer.BodyFormat = 0 
        Mailer.MailFormat = 0 
    end if
    If Orderattachmentcount>0 then
        for i = 0 to orderattachmentcount-1
            Mailer.AttachFile orderattachments(i)
            response.write "adding " & orderattachments(i)
        next
        Orderattachmentcount=0
    end if            
        Mailer.Send
        response.write "mail sent"
        set mailer=nothing
        exit sub
end if
Je travaille à partir d'une licence Cybershop, les paramètres commençant par un "x" sont inscrits dans la partie admin.
Si j'enlève la pièce jointe, le mail part convenablement, si je la laisse, je reçois un message d'erreur :
Microsoft VBScript runtime error '800a000d'

Type mismatch: 'Orderattachments'

/administration/shopmail.asp, line 60

La ligne 60 étant celle-ci : Mailer.AttachFile orderattachments(i)

Je ne sais pas comment fonctionne AttachFile, je ne sais donc pas comment résoudre ce problème.

Quelqu'un aurait-il une solution?

Merci !