Avatar billede funstuff.dk Nybegynder
16. december 2001 - 22:34 Der er 3 kommentarer og
2 løsninger

Vedhæft fil i email..?

Hej..

Er der nogle der kan gi et simpelt eksempel på hvordan man kan vedhæfte en fil til en email og sende den..?

Helt med JMail eller ASPMail komponentet..

På forhånd tak..
Avatar billede cthun Nybegynder
16. december 2001 - 22:42 #1
<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>
Avatar billede cthun Nybegynder
16. december 2001 - 22:43 #2
  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>

Avatar billede cthun Nybegynder
16. december 2001 - 22:48 #3
Dette script kræver også at du har w3.Upload, som du kan downloade fra http://www.dimac.se
Avatar billede bobbedude Nybegynder
17. december 2001 - 07:18 #4
<%
    \' change to address of your own SMTP server
    strHost = \"mail.atlantech.net\"

    If Request(\"Send\") <> \"\" Then
       
        Set Mail = Server.CreateObject(\"Persits.MailSender\")
        \' enter valid SMTP host
        Mail.Host = strHost

        Mail.From = \"info@persits.com\"
        Mail.FromName = \"Persits Software, Inc.\"
        Mail.AddAddress Request(\"To\")

        \' Attach two files in the same directory (any file type can be attached)
        strPath = Server.MapPath(\".\")
        Mail.AddAttachment strPath & \"\\ps_logo.gif\"
        Mail.AddAttachment strPath & \"\\wehave.gif\"
       
        \' message subject
        Mail.Subject = \"Logo & Motto\"
        \' message body
        Mail.Body = \"Persits Software logo and motto images are attached.\"

        Mail.Send    \' send message

        Response.Write \"Success!<P>\"
    End If
%>


<HTML>
<HEAD>
<TITLE>AspEmail: Attachments.asp</TITLE>
</HEAD>
<BODY BGCOLOR=\"#FFFFFF\">
<H2>AspEmail: Attachments.asp</h2>

<FORM ACTION=\"Attachments.asp\">
Enter email: <INPUT TYPE=\"TEXT\" NAME=\"To\">
<INPUT TYPE=SUBMIT NAME=\"Send\" VALUE=\"Send\">
</FORM>


</BODY>
</HTML>
Avatar billede funstuff.dk Nybegynder
17. december 2001 - 20:02 #5
takker
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester