Split issue with a for loop

Posted on 2011-03-17
Last Modified: 2012-05-11
I have a problem with a split taking in multiple email address parsed by semicolons. The for loop repeats the data from the previous email if I have back to back "::". How do I validate while space created by the split to eliminate duplicate emails going out.
If (Cstr(Request("Submit")) <>  "") then

SendtoEmail = Request.Form("email_Address")
additionalText = Request.Form("remarks")
cc = Request.Form("cc")
Response.Write(SendtoEmail) & "<br>"
Response.Write(additionalText) & "<br>"
Response.Write(cc) & "<br>"

    Dim strEmail
    Dim p
    Dim i
    Dim e
    Dim c
    SendtoEmail = Replace(SendtoEmail, "; ", ";")
    SendtoEmail = Replace(SendtoEmail, " ", ";")
    SendtoEmail = Replace(SendtoEmail, ",", ";")
    strEmail = split(SendtoEmail, ";")
    Response.Write(strEmail) & "<BR>"
    for i = lbound(strEmail) to Ubound(strEmail)
    p = strEmail(i)
    Response.Write(p) & "<BR>"
    lstrEmail = replace(split(p, "@")(0),"", "")
    Response.Write(lstrEmail) & "<BR>"
    If Len(lstrEmail) <=0 Then
    Response.Write(Len(lstrEmail)) & "<BR>"
    SendtoEmail = lstrEmail+""
    Response.Write(SendtoEmail) & "<BR>"
    If cc ="Yes" then
	senderEmail = mail
	senderEmail = ""
	end if
	'Response.Write(senderEmail) & "<br>"
	dateTime = Now
	'Response.Write(dateTime) & "<BR>"
	set emaildata = Server.CreateObject("ADODB.recordset")
	  emaildata.Open Opinion,dataConn, 2, 3
	set sysMail = Server.CreateObject("CDO.Message")
	sysMail.Configuration.Fields("") = ""
	sysMail.Configuration.Fields("") = 2
	sysMail.From = ""
	sysMail.To = SendtoEmail = senderEmail
	sysMail.Subject = "Your co-worker "&senderCN&" emailed you this story '"&title&".' "
	HTML = "<html>" & vbCrLF
	HTML = HTML & "<body>" & vbCrLf
	HTML = HTML & "<table  bordercolor='#cccccc' border='1' align='center' width='700px' cellpadding='8' cellspacing='0' style='font-family:verdana;font-size:11px;'>" & vbCrLf
	HTML = HTML & "<tr><td >" & vbCrLf
	HTML = HTML & " <img name='"&siteName&"' src='"&commonImages&logoPath&"' type='image' /><br ><hr><br>" & vbCrLf
	HTML = HTML & "<span style='font-family:verdana;font-size:14px; color:#663399;'>Your co-worker "&CN&" emailed you this story <b>'"&title&".'</b><br><br> To read the story <a href='"&NGUID&"'> <b>Click Here</a></b></span><br/><br>" & vbCrLf& vbCrLf
	HTML = HTML & "<span style='font-family:verdana;font-size:14px; color:#663399;'><b>Remarks by sender:</b>"&additionalText&"</span>"
	HTML = HTML & "<table  bordercolor='#cccccc' align='center' width='100%' cellpadding='8' cellspacing='0' style='font-family:verdana;font-size:11px;' bgcolor='#f5f5f5'><tr><td>"
	HTML = HTML &"</td></tr></table>"
	HTML = HTML & "</td></tr></table>" & vbCrLf
	HTML = HTML & "</body>" & vbCrLf
	HTML = HTML & "</html>" & vbCrLf 
	sysMail.HTMLBody = HTML
    end if

Open in new window

Question by:glstephens08
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 33

Accepted Solution

Big Monty earned 500 total points
ID: 35159941
You could always replace :: with :

SendtoEmail = Replace(SendtoEmail, "::", ":")

otherwise you can write a if statement to check if strEmail(i) is blank

if p <> "" then
'-- continue processing code

Author Closing Comment

ID: 35160205
Thanks, If p <> "" Then seems obvious now, but I was drawing a blank.

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Hide cell in a table 2 41
send email part1 9 51
Making Table Thru ASP Response.write 5 35
Can't select treeview node from iframe 2 51
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question ( here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question