How to send by mail the file entered in a form

I have a formulary and the user enter informations about a mail that will be send
(sender, receiver, subject, body of mail and attachment of mail)

Actually, i can send a mail but the attachment is not transmitted (

#set($pageattachments=[$request.attach]) ##The file put in the <input>

#set($result = $xwiki.mailsender.sendHtmlMessage($context.user,$emaila, $emailcc, $emailbcc, $subject ,“$emailcontent”, $doc.getContent(), $pageattachments)) ## send mail

<form action="" id="BP" method="POST">
<input type="text" name="sujet" value="Voici le sujet de mon email" size="50" />
<input type="file" name="attach" /> ## in the form
<input type="submit" value="Valider" />

Do you have an idea ?


PS : There are some variables i have not shown here that permit to know when we are clicked on submit

Furthermore, I have an other idea : to store on hard disk attachment of input file (), send by mail this attacment and delete the attachment on the hard disk