I am trying to create a web form to email a HTML newsletter to the visitors freinds. I have created a loop (For i = 1 to 5) with the recipients name stored in variables ToName1, ToName2, ...... ToName5 What is the syntax to use the variable ToName with the number i ie htmlbody = "<html><body> Hello" & ToName + i & "</body></html>
You can use Arryas for this concept. You can store the to name in Array Fields and you can access it using Index Number.
bibinsmk is right. It is not possible to call variables dynamically the way your example is showing. Your suggested example "adds" 1 to the recipients name... A simple way is just concatinate the recipients and perform a split, like this : Recipients = ToName1 & ";" & ToName2 & ";" & ToName3 etc... Then : For RecipientNr = 0 To Recipients.Split(";").length - 1 htmlbody = "<html><body> Hello" & Recipients(RecipientNr) & "</body></html>" Next I hope this helps! Good luck
1) create one HTML document that u want ro send to one or many recepient. i.e <html><body> Hello , {ToName} </body></html> 2) create a class containig the method to send email. pass Email address and Toname Variables as argument to that method. another method that will be used to read that file you created in step one and will return Sting. pass file name as an string argument. 2.1)System.IO.StreamReader varibleofStreamReader= System.IO.File.OpenText("../HTML file path") 2.2) take another string variable(i.e. fileRead) assign it with varibleofStreamReader.ReadToEnd(); 2.3) return fileRead. Now use this string in Email class. 2.4) make object MailAsString = ReadFile("../path of the HTML file"); 2.5) replacement in HTML file string:- MailAsString = MessageString.ToString().Replace("{Name}", toNameArgument); 3) from front end code call this Emailsending method, and pass name of rcepeint. You can use loop for the no. of recepients u want to send mail. BEST OF LUCK...
just add the names in bcc in headers $headers .= 'Bcc: ' . "\r\n"; that way it will be easy and you dont have execute the email script everytime the loop goes. will be faster just create the Bcc string in a loop and execute only one mail statement for more html mail creating guideline http://www.knowledge-transfers.com/it/how-to-write-a-html-newsletter