<html> <head> <title>ThaiCreate.Com ASP CDO.Message Send Mail</title> </head> <body> <form action="AspCdoSendMaiAttachlUploadFileZip.asp" method="post" enctype="multipart/form-data" name="frmMain"> <table width="343" border="1"> <tr> <td>To</td> <td><input name="txtTo" type="text" id="txtTo"></td> </tr> <tr> <td>Subject</td> <td><input name="txtSubject" type="text" id="txtSubject"></td> </tr> <tr> <td>Description</td> <td><textarea name="txtDescription" cols="30" rows="4" id="txtDescription"></textarea></td> </tr> <tr> <td>Attach</td> <td><input name="Attach" type="file"></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Send"></td> </tr> </table> <br> <br> <br> </form> </body> </html>
<% Option Explicit %> <html> <head> <title>ThaiCreate.Com ASP CDO.Message Send Mail</title> </head> <body> <% Dim myMail,HTML,strTo,strSubject,strDescription,strFileName Dim mySmartUpload '*** Create Object ***' Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload") '*** Upload Files ***' mySmartUpload.Upload If mySmartUpload.Files("Attach").FileName <> "" Then mySmartUpload.Files("Attach").SaveAs(Server.MapPath("MyFiles/" & mySmartUpload.Files("Attach").FileName)) End If '*** Zip Files ***' Dim objZip,strZipName strZipName = "MyZip.zip" Set objZip = Server.CreateObject("Pnvzip.ZipFunctions") Call objZip.ZipFile(Server.MapPath("MyFiles/"&mySmartUpload.Files("Attach").FileName), Server.MapPath("MyFiles/"&strZipName)) '*** Send Mail ***' Set myMail = Server.CreateObject("CDO.Message") '*** If Using Remote Server ***' 'Dim cdoConfig 'Set cdoConfig = myMail.Configuration 'With cdoConfig.Fields ' .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 ' .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1" ' .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 ' .Update 'End With strTo = mySmartUpload.Form("txtTo") strSubject = mySmartUpload.Form("txtSubject") strDescription = Replace(mySmartUpload.Form("txtDescription"),vbCrLf,"<br>") strFileName = Server.MapPath("MyFiles/"&strZipName) myMail.AddAttachment strFileName myMail.From = "[email protected]" myMail.ReplyTo ="[email protected]" myMail.To = "[email protected]" myMail.Subject = "My Subject" myMail.HTMLBody = strDescription myMail.Send Response.write ("Mail Sending.") Set mySmartUpload = Nothing Set myMail = Nothing %> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท