Pièce jointe avec Jmail

Pièce jointe avec Jmail - ASP - Programmation

Marsh Posté le 05-08-2005 à 14:23:32    

Je rame un peu avec les composantes Jmail. Je veux envoyer un mail avec un fichier (txt) en pièce jointe.
Je suis content j'arrive à envoyer mon mail (faut pas rire ca m'a pris la matinée...c'est dur le vendredi). Bon le seul hic c'est que:
1) le mail est reconnu comme SPAM (ca encore c'est pas bien grave)
2) la pièce jointe n'apparait pas comme pièce jointe mais semble être incluse au corps du message, semble car ca ne ressemble plus à rien du tout (une cascade de caractères divers, de quoi s'éclater au Boggle  :pt1cable:  ) mais le volume du fichier semble bien indiquer que j'ai envoyé mes donnéees.
 
j'utilise donc Jmail avec ça:  
dir = "d:\chemin_confidentiel\test\"
Fnm=dir&"exportbase.txt"
 
msg.AddAttachment Fnm

 
Si quelqu'un peut me dire comment avoir une pièce jointe au format convenable et SURTOUT détaché du reste du mail (l'utilisateur devant par la suite ouvrir le fichier texte sous Excel....)
 :hello:  merci par avance

Reply

Marsh Posté le 05-08-2005 à 14:23:32   

Reply

Marsh Posté le 05-08-2005 à 16:36:43    

Encore moi!
J'ai lu dans un forum que la pièce jointe invisible pourrait être du à la version... la version de quoi c'est un bonne question je vous le mets texto:
"Bon, mon hebergeur qui me fournit le composant est en version 3.0, chez DIMAC ils en sont à la 4.4...  
Ceci explique peut-etre cela... "
Est-ce que mon problème peut venir de là? Comment déterminer la version que j'utilise?
 
Bref toujours est-il que pour que mon problème n'en soit plus un il faut que l'utilisateur recoive le fichier chez lui (et pas déjà ouvert, physiquement...). Qu'il le recoive par mail ou bien qu'il le télécharge je m'en moque un peu...

Reply

Marsh Posté le 07-08-2005 à 17:34:50    

Voila l'exemple donné par Dimac  
 

Citation :

Attaching files to your w3 JMail emails requires that the file you wish to attach resides on the webserver. However, using w3 Upload, you can let the user upload the file to the webserver and attach it on the fly. Check out the samples below to find out more...
 
First of all we a form where the user can enter his email message and select which file to attach.
 
   JMailUpload.asp
<html>
<head>
<title>emailform</title>
</head>
<body>
<font face="verdana, arial" size="2"><b>
<form method="post" action="JmailUploadProcess.asp" ENCTYPE="multipart/form-data">
Complete this form and click the submit-button. We will answer your
questions as soon as possible.
<br><br>
Your name <br>
<input type="text" size="25" name="name"><br>
 
Your email <br>
<input type="text" size= "25" name= "email"><br>< /FONT>
 
Recipient email <br>
<input type= "text" size= "25" name= "recipient"><br>< /FONT>
 
State your business <br>
<select name="subject" size="1">
<option value="help">help
<option value="tips">tips
<option value="other">other
</select>
<br>
 
Enter your question <br>
<textarea name="body" cols="40" rows="15" wrap="PHYSICAL"></textarea>
<br>
 
Attachments <br>
<input type="file" name="attachment">
<br>
<br>
<input type="submit" value=" Submit ">
</form>
</b></font>
</body>
</html>
 
Okay, Now lets put all that info into our email. Again, notice how we use the Upload object instead of the Request object.
 
   JMailUploadProcess.asp
 
<%@LANGUAGE="VBSCRIPT" %>
<HTML>
<BODY>
<%
 
    ' Create the JMail message Object
    set msg = Server.CreateOBject( "JMail.Message" )
    Set upload = Server.CreateObject( "w3.Upload" )
 
    ' Check for attachments and add them to the email
    set attachment = upload.Form( "attachment" )
    if attachment.IsFile then
      msg.AddCustomAttachment attachment.filename, attachment.item, false
    end if
 
    ' Set logging to true to ease any potential debugging
    ' And set silent to true as we wish to handle our errors ourself
    msg.Logging = true
    msg.silent = true
 
    ' Get the form variables, using the upload object
    Name = upload.Form("name" )
    SenderEmail = upload.Form("email" )
    Subject = "Regarding " & upload.Form ("subject" )
    Recipient = upload.Form("recipient" )
    Body = upload.Form("body" )
 
    ' And apply them to the message
    msg.From = SenderEmail
    msg.FromName = Name
 
    msg.AddRecipient Recipient
    msg.Subject = Subject
 
    msg.Body = Body
 
    ' To capture any errors which might occur, we wrap the call in an IF statement
    if not msg.Send( "mail.myDomain.net" ) then
      Response.write "<pre>" & msg.log & "</pre>"
    else
      Response.write "Message sent succesfully!"
    end if
 
 
    ' And we're done! the message has been sent.  
 
%>
</BODY>
</HTML>
 
   
 
   
 
There you go! Notice how w3 Upload never actually saves the file to your disc, but rather just attaches the file to the email. Quite nifty as your webserver wont get cluttered with files.

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed