web 2.0

How to use ASP & Sending Mail with CDO.Message (Form Upload , Zip & Attachment file)

How to use ASP & Sending Mail with CDO.Message (Form Upload , Zip & Attachment file) This is learn/tutorial asp developers how to using ASP script Sending Mail with CDO.Message (Form Upload , Zip & Attachment file)

ShotDev Focus:
- ASP & Sending Mail with CDO.Message (Form Upload , Zip & Attachment file)

Example

asp_cdomessage_zip_attachment1.asp

  1. <html>  
  2. <head>  
  3. <title>ShotDev.Com Tutorial</title>  
  4. </head>  
  5. <body>  
  6. <form action="asp_cdomessage_zip_attachment2.asp" method="post" enctype="multipart/form-data" name="frmMain">  
  7. <table width="343" border="1">  
  8. <tr>  
  9. <td>To</td>  
  10. <td><input name="txtTo" type="text" id="txtTo"></td>  
  11. </tr>  
  12. <tr>  
  13. <td>Subject</td>  
  14. <td><input name="txtSubject" type="text" id="txtSubject"></td>  
  15. </tr>  
  16. <tr>  
  17. <td>Description</td>  
  18. <td><textarea name="txtDescription" cols="30" rows="4" id="txtDescription"></textarea></td>  
  19. </tr>  
  20. <tr>  
  21. <td>Attach</td>  
  22. <td><input name="Attach" type="file"></td>  
  23. </tr>  
  24. <tr>  
  25. <td>&nbsp;</td>  
  26. <td><input type="submit" name="Submit" value="Send"></td>  
  27. </tr>  
  28. </table>  
  29. <br>  
  30. <br>  
  31. <br>  
  32. </form>  
  33. </body>  
  34. </html>  

asp_cdomessage_zip_attachment2.asp

  1. <html>  
  2. <head>  
  3. <title>ShotDev.Com Tutorial</title>  
  4. </head>  
  5. <body>  
  6. <%  
  7. Dim myMail,HTML,strTo,strSubject,strDescription,strFileName  
  8.   
  9. Dim mySmartUpload  
  10. '*** Create Object ***'  
  11. Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")  
  12.   
  13. '*** Upload Files ***'  
  14. mySmartUpload.Upload  
  15.   
  16. If mySmartUpload.Files("Attach").FileName <> "" Then  
  17. mySmartUpload.Files("Attach").SaveAs(Server.MapPath("MyFiles/" & mySmartUpload.Files("Attach").FileName))  
  18. End If  
  19.   
  20. '*** Zip Files ***'  
  21. Dim objZip,strZipName  
  22. strZipName = "MyZip.zip"  
  23. Set objZip = Server.CreateObject("Pnvzip.ZipFunctions")  
  24. Call objZip.ZipFile(Server.MapPath("MyFiles/"&mySmartUpload.Files("Attach").FileName), Server.MapPath("MyFiles/"&strZipName))  
  25.   
  26. '*** Send Mail ***'  
  27. Set myMail = Server.CreateObject("CDO.Message")  
  28.   
  29. strTo = mySmartUpload.Form("txtTo")  
  30. strSubject = mySmartUpload.Form("txtSubject")  
  31. strDescription =  Replace(mySmartUpload.Form("txtDescription"),vbCrLf,"<br>")  
  32. strFileName = Server.MapPath("MyFiles/"&strZipName)  
  33.   
  34. myMail.AddAttachment strFileName  
  35.   
  36. myMail.From = "webmaster@shotdev.com"  
  37. myMail.ReplyTo ="shotdev@hotmail.com"  
  38. myMail.To   = "member@shotdev.com"  
  39. myMail.Subject = "My Subject"  
  40. myMail.HTMLBody = strDescription  
  41.   
  42. myMail.Send  
  43.   
  44. Response.write ("Mail Sending.")  
  45.   
  46. Set mySmartUpload = Nothing  
  47. Set myMail = Nothing  
  48. %>  
  49. </body>  
  50. </html>  

Create a asp file and save to path root-path/myasp/

Run
http://localhost/myasp/asp_cdomessage_zip_attachment1.asp

Screenshot

ASP & Sending Mail with CDO.Message (Form Upload , Zip & Attachment file)

ASP & Sending Mail with CDO.Message (Form Upload , Zip & Attachment file)
.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.