Connecting Tech Pros Worldwide Forums | Help | Site Map

Simple Loop

Member
 
Join Date: Jul 2007
Posts: 70
#1: Jun 25 '09
Hi

I'm trying to make a simple loop to work within an email app.

All I would like to do is fill in the BCC field, but the information is created dynamically on the previous page on my website.

So information passed looks like
Request.Form("CompanyEmail") which displays the result email1.com, email2.com

All I am trying to do is put the result into the MyMail.BCC field.

My Code:

Expand|Select|Wrap|Line Numbers
  1. dim varE, strItem
  2. varE = Request.Form("CompanyEmail")
  3. varE= Replace(varE," ","")
  4. varE = Split(varE,",")
  5.     for each strItem in varE
  6.                          Response.Write(strItem)
  7.              MyMail.BCC = MyMail.BCC + strItem
  8.     Next
  9. Response.Write(MyMail.BCC)
  10. MyMail.BCC = Replace(MyMail.BCC," ","""")    
  11. Response.Write(MyMail.BCC)
  12.  
Line 6 displays the result: email1.com email2.com
Line 9 displays the result: "email1.com email2.com" (please note the quote marks are created by the progam and not by me)
Line 11 displays the result "email1.com""email2.com "" , """ <">, "email1.com" error '8004020f'

I have no idea where the extra symbols come from on Line11

Because these 2 emails have to go into the BCC field, I have to have them spereated by ""; (eg "email1"; "email2"; (hence line 10)).

Any one got a better idea on how to do this?

Thanks

GazMathias's Avatar
Expert
 
Join Date: Oct 2008
Location: Bristol, United Kingdom
Posts: 145
#2: Jun 26 '09

re: Simple Loop


Hi there,

Try this:

Expand|Select|Wrap|Line Numbers
  1. dim varE, strItem, BCC, tmp
  2. varE = Request.Form("CompanyEmail")
  3. varE= Replace(varE," ","")
  4. varE = Split(varE,",")
  5.     for each strItem in varE
  6.          tmp = chr(34) & strItem & chr(34) & "; "
  7.          BCC = BCC & tmp
  8.     Next
  9.  
  10.     BCC = left(BCC,len(BCC)-2)
  11.  
  12. Response.Write(BCC)
  13. MyMail.BCC = BCC
  14.  
It outputs this:

"email1.com"; "email2.com"; "email3.com"

Gaz
Member
 
Join Date: Jul 2007
Posts: 70
#3: Jun 26 '09

re: Simple Loop


Hi Gaz

It worked perfectly, thank you for that. If I understand correctly, I had to create the finished string and then send it to the MyMail.CC first instead of trying to build the MyMail.CC on the fly?

Thank you for your help

Dave
GazMathias's Avatar
Expert
 
Join Date: Oct 2008
Location: Bristol, United Kingdom
Posts: 145
#4: Jun 26 '09

re: Simple Loop


Quote:
If I understand correctly, I had to create the finished string and then send it to the MyMail.CC first instead of trying to build the MyMail.CC on the fly
I guess it is just a matter of preference.

Gaz.
Member
 
Join Date: Jul 2007
Posts: 70
#5: Jun 26 '09

re: Simple Loop


You're way does seem more logical, although I'm sure it is just what 'one' preferrs!

Thank you again
Reply