note 103952 added to ref.mail
| From: | rahulpandey2009 at hotmail dot com | Date: | Fri, 13 May 2011 13:51:02 +0000 |
| Subject: | note 103952 added to ref.mail | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179681@lists.php.net to get a copy of this message | ||
Upload - Send an email with attachment
<%
'Sample file Form-Email.asp
' Let's you send one an email with one or more attachments.
'Create upload form
Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm")
'Do not upload data greater than 1MB.
Form.SizeLimit = 100*1024
'
Const fscompleted = 0
If Form.State = fscompleted Then 'completed
ProcessForm
End If
Sub ProcessForm
Dim eFrom, eTo, Subject, Message
'get source form fields - From, To, Subject and Message
eFrom = Form("From")
eTo = Form("To")
Subject = Form("Subject")
Message = Form("Message")
Dim objNewMail, File, FileName, FS, TempFolder
Set FS = CreateObject("Scripting.FileSystemObject")
'Get temporary folder
TempFolder = FS.GetSpecialFolder(2) & "\emailtemp"
'Create a new email message
Set objNewMail = CreateObject("CDONTS.NewMail")
Const CdoMailFormatMime = 0
objNewMail.MailFormat = CdoMailFormatMime
'Save source files to temporary folder
'Add these files to the new e-mail
For Each File In Form.Files
'If source file is specified.
If Len(File.FileName) > 0 Then
FileName = TempFolder & "\" & File.FileName
File.SaveAs FileName
objNewMail.AttachFile FileName
End If
Next
'Send the new email
objNewMail.Send eFrom, eTo, Subject, Message
'delete temporary files
For Each File In Form.Files
If Len(File.FileName) > 0 Then
FileName = TempFolder & "\" & File.FileName
FS.DeleteFile FileName
End If
Next
End Sub
%>
<br>Sample For <A Href=http://www.motobit.com>HugeASP upload</A>
<br> Let's you send one an email with one or more attachments.
<br> File size limit Is <%=Form.SizeLimit%> B (<%=Form.SizeLimit \ 1024 %>kB).
<Table Border=0>
<form method="POST" ENCTYPE="multipart/form-data">
<tr><td> From : </td><td><input Name=From
Size=50></td></tr>
<tr><td> To : </td><td><input Name=To Size=50></td></tr>
<tr><td> Subject : </td><td><input Name=Subject
Size=80></td></tr>
<tr><td ColSpan=2> Message:
<br><TextArea Name=Message Cols=76 Rows=10></TextArea>
</td></tr>
<tr><td ColSpan=2>E-Mail Attachments:
<Div ID=files>
Attachment 1 : <input type="file" name="File1">
</Div>
<Input Type=Button Value="Add a file" OnClick=return(Expand())
Style="border=0;background=yellow;cursor:hand">
</td></tr>
<tr><td ColSpan=2 Align=Right>
<input Name=SubmitButton Value="Send email >>"
Type=Submit></td></tr>
</Form>
</Table>
<Script>
//Script To add a attachment file field
var nfiles = 1;
Function Expand(){
nfiles++
var adh = '<BR> Attachment '+nfiles+' : <input type="file"
name="File'+nfiles+'">';
files.insertAdjacentHTML('BeforeEnd',adh);
return false;
}
</Script>
----
Server IP: 69.147.83.197
Probable Submitter: 122.172.18.243
----
Manual Page -- http://www.php.net/manual/en/ref.mail.php
Edit -- https://master.php.net/note/edit/103952
Del: integrated -- https://master.php.net/note/delete/103952/integrated
Del: useless -- https://master.php.net/note/delete/103952/useless
Del: bad code -- https://master.php.net/note/delete/103952/bad+code
Del: spam -- https://master.php.net/note/delete/103952/spam
Del: non-english -- https://master.php.net/note/delete/103952/non-english
Del: in docs -- https://master.php.net/note/delete/103952/in+docs
Del: other reasons-- https://master.php.net/note/delete/103952
Reject -- https://master.php.net/note/reject/103952
Search -- https://master.php.net/manage/user-notes.php