Assume you want
About the application
visitors to subscribe to a newsletter through a subscription form and send mail to the e-mail ids of subscribed users. The
application should also allow subscribers to unsubscribe from the news
letter. The sample application Subscribe to Newsletter illustrates this scenario.The application has three forms:
Subscription Form :
The form to subscribe to the newsletter. It has the Name and e-mailid fields to enable visitors to subscribe to the newsletter by specifying their e-mail ids. There is also one hidden field “isUnsubscribed” to check the status of each subscription. This field is hidden when the form is loaded. The on add ->on load script given below, hides the isUnsubscribed field, when form is loaded.
on add |
Send Mail Form :
This form is used by the owner to send mails to the subscribers mailing list. It has the Send decision check-box field which when set to “true” will send e-mails to the subscriber mailing list. This is achieved by adding on user input script to the Send field as given below.
Send |
Code Explanation
if (input.Send) – The if statements will be executed if the Send decision check-box is set to true.
for each r in Subscription_Form [isUnsubscribed == false] – Here, isUnsubscribed is a Decision Check field and r is a variable that stores the records whose isUnsubscribed status is false.
sendmail – Send mail to the e-mail id specified in the row variable r.
Unsubscribe form
The form used to unsubscribe from the newsletter. This form contains the e-mailId field, using which the user unsubscribes from the newsletter. When a user submits his e-mailid, the on add ->on success script added to this form, updates the decision checkbox field isUnsubscribed in the Subscription form to true, as shown in the code given below:
on add |
Code Explanation:
temp = Subscription_Form [EmailId == input.EmailId];
-The above code will fetch records from the Subscription Form whose EmailId is equal to the EmailId specified in this form, and store it in a collection variable named temp.
temp.isUnsubscribed = true;
- The above code sets the isUnsubscribed field in the fetched record to true.
Related Links
To install the application,
- Download the http://creator.zoho.com/exportScript.do?appid=89597000000135240&fileType=.ds&sharedBy=sampleapps
- Install the application to your account.Click here to learn how to install using the script file (.ds file)