Simple Loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DaveRook
    New Member
    • Jul 2007
    • 147

    Simple Loop

    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("C ompanyEmail") 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:

    Code:
    dim varE, strItem
    varE = Request.Form("CompanyEmail")
    varE= Replace(varE," ","")
    varE = Split(varE,",")
    	for each strItem in varE
                             Response.Write(strItem)
    			 MyMail.BCC = MyMail.BCC + strItem
    	Next
    Response.Write(MyMail.BCC)
    MyMail.BCC = Replace(MyMail.BCC," ","""")	
    Response.Write(MyMail.BCC)
    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""em ail2.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
    Recognized Expert New Member
    • Oct 2008
    • 228

    #2
    Hi there,

    Try this:

    Code:
    dim varE, strItem, BCC, tmp
    varE = Request.Form("CompanyEmail")
    varE= Replace(varE," ","")
    varE = Split(varE,",")
        for each strItem in varE
             tmp = chr(34) & strItem & chr(34) & "; "
             BCC = BCC & tmp
    	Next
    	
    	BCC = left(BCC,len(BCC)-2)
    
    Response.Write(BCC)
    MyMail.BCC = BCC
    It outputs this:

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

    Gaz

    Comment

    • DaveRook
      New Member
      • Jul 2007
      • 147

      #3
      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

      Comment

      • GazMathias
        Recognized Expert New Member
        • Oct 2008
        • 228

        #4
        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.

        Comment

        • DaveRook
          New Member
          • Jul 2007
          • 147

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

          Thank you again

          Comment

          Working...