Auto mail

Results 1 to 2 of 2

Thread: Auto mail

  1. #1
    Sanjoy Dutta Guest

    Default Auto mail

    How can I fire an automated mail to all my registered users on the first day of every month even when nobody is viewing any page of my site ..

  2. #2
    Aporter Guest

    Default RE: Auto mail

    Sanjoy - if you are using IIS, the article below will show you how. You don&#039t have to make the email message HTML format. You could simply make it text as shown below, which I copied from this site at:<BR><BR>Hope it helps...<BR><BR>-----------------------------------------------<BR>Dim txtSubject<BR>txtSubject = "Hello Scott! We were wanting your advice on some programming issues. Please come to Redmond at your earliest convenience for a very fat check!" <BR><BR>objCDO.Subject = "Attn: Scott, we need you!!"<BR>objCDO.Body = txtSubject<BR>objCDO.Send<BR>---------------------------------------------------<BR><BR><BR>The information in this article applies to:<BR>* Microsoft Internet Information Server 4.0 <BR>* Microsoft Internet Information Services version 5.0<BR><BR><BR>SUMMARY<BR>Windows NT Option Pack (NTOP) and Windows 2000 install by default a Simple Mail Transfer Protocol (SMTP) service that can be used for a variety of purposes, usually using Active Server Pages (ASP) for e-mail-based HTML form handling.<BR><BR>The purpose of this article is to describe the process in creating scheduled mail-outs using Windows Script Host (WSH) and the e-mail features of the SMTP service&#039s CDONTS.NewMail object. <BR><BR>MORE INFORMATION<BR>The following example steps you through creating a WSH script to send mail, as well as a text file that you can update for the mail contents and a scheduled task to send the mail. <BR>1. The first step in setting up any scheduled activity is to ensure that the scheduler service is running."<BR>a. Click Start on the task bar, click Settings, and then Control Panel.<BR>b. Double-click the Services applet in Control Panel.<BR>c. Scroll down to the Task Scheduler service.<BR>d. Ensure that Status states Running.<BR>e. Ensure that Startup states Automatic.<BR>f. Click Close to exit the services applet and close Control Panel.<BR><BR>2. Create a text file with the following contents and save it as C:Mailout.txt on your computer: <BR>3. &#060;p&#062;This is line 1.&#060;/p&#062;<BR>&#060;p&#062;This is line 2.&#060;/p&#062; <BR><BR>4. Create the WSH script to read the text file you just created. Copy the following code and save it as "C:mailout.vbs" on your computer. To customize the sender/receiver, change the value of the strFrom and strTo variables: <BR>5. &#039--------------------------------------------------------------------<BR>6. &#039<BR>7. &#039 Mailout using CDONTS.NewMail<BR>8. &#039<BR>9. &#039--------------------------------------------------------------------<BR>10. <BR>11. &#039 declare all variables<BR>12. Option Explicit<BR>13. Dim objSendMail<BR>14. Dim strTo, strFrom<BR>15. Dim strSubject, strBody<BR>16. <BR>17. &#039 mail constants (some are for reference)<BR>18. Const CdoBodyFormatHTML = 0 &#039 Body property is HTML<BR>19. Const CdoBodyFormatText = 1 &#039 Body property is plain text (default)<BR>20. Const CdoMailFormatMime = 0 &#039 NewMail object is in MIME format<BR>21. Const CdoMailFormatText = 1 &#039 NewMail object is plain text (default)<BR>22. Const CdoLow = 0 &#039 Low importance<BR>23. Const CdoNormal = 1 &#039 Normal importance (default)<BR>24. Const CdoHigh = 2 &#039 High importance<BR>25. <BR>26. strFrom = "" &#039 change to your email address<BR>27. strTo = "" &#039 change to the recipient&#039s address<BR>28. strSubject = "Test Message" &#039 change to your subject<BR>29. <BR>30. &#039 this line calls the ReadFile() function to read the page contents<BR>31. strBody = ReadFile("C:MAILOUT.TXT")<BR>32. <BR>33. &#039 this line calls the MakePage() function to format the page as HTML<BR>34. strBody = MakePage(strSubject,strBody)<BR>35. <BR>36. &#039 the following section creates the mail object and sends the mail<BR>37. Set objSendMail = CreateObject("CDONTS.NewMail")<BR>38. objSendMail.From = strFrom<BR>39. objSendMail.To = strTo<BR>40. objSendMail.Subject = strSubject & " (" & Date() & ")"<BR>41. objSendMail.Body = strBody<BR>42. <BR>43. objSendMail.BodyFormat = CdoBodyFormatHTML<BR>44. objSendMail.MailFormat = CdoMailFormatMime<BR>45. objSendMail.Importance = CdoNormal<BR>46. <BR>47. objSendMail.Send<BR>48. Set objSendMail = Nothing<BR>49. <BR>50. &#039 this function returns a properly formatted HTML page<BR>51. Function MakePage(txtSubject, txtBody)<BR>52. Dim txtTemp<BR>53. txtTemp = "&#060;HTML&#062;" & vbCrLf<BR>54. txtTemp = txtTemp & "&#060;HEAD&#062;&#060;TITLE&#062;"<BR>55. txtTemp = txtTemp & txtSubject<BR>56. txtTemp = txtTemp & "&#060;/TITLE&#062;&#060;/HEAD&#062;" & vbCrLf<BR>57. txtTemp = txtTemp & "&#060;BODY&#062;" & vbCrLf<BR>58. txtTemp = txtTemp & "&#060;H2&#062;" & txtSubject & "&#060;/H2&#062;" & vbCrLf<BR>59. txtTemp = txtTemp & txtBody & vbCrLf<BR>60. txtTemp = txtTemp & "&#060;/BODY&#062;" & vbCrLf<BR>61. txtTemp = txtTemp & "&#060;/HTML&#062;"<BR>62. MakePage = txtTemp<BR>63. End Function<BR>64. <BR>65. &#039 this function opens a file and returns the file&#039s contents<BR>66. Function ReadFile(txtFile)<BR>67. Dim txtTemp, objFS, objFL<BR>68. Set objFS = CreateObject("Scripting.FileSystemObject")<BR>69. Set objFL = objFS.OpenTextFile(txtFile)<BR>70. Do While Not objFL.AtEndOfStream<BR>71. txtTemp = txtTemp & objFL.ReadLine<BR>72. txtTemp = txtTemp & vbCrLf<BR>73. Loop <BR>74. objFL.Close<BR>75. Set objFS = Nothing<BR>76. ReadFile = txtTemp<BR>End Function <BR><BR>77. Create a task to schedule the mail-out to be sent. Open a command session and enter something similar to the following examples:<BR>a. The following task will run once at 9:00pm. <BR>AT 9:00pm Cscript.exe C:Mailout.vbs <BR><BR>b. This task will run every Monday at 6:00am. <BR>AT 6:00am /every:M Cscript.exe C:Mailout.vbs <BR><BR>c. This task will run on the first of every month at 1:00am. <BR>AT 1:00am /every:1 Cscript.exe C:Mailout.vbs <BR><BR>78. <BR>79. Depending on the scheduled time that you chose for the task above, your e-mail will be sent when the time occurs.<BR>For more information on Microsoft&#039s scripting technologies, please see the following Web site: <BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts