Solved

Split issue with a for loop

Posted on 2011-03-17
2
207 Views
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),"company.com", "")
    Response.Write(lstrEmail) & "<BR>"
    
    If Len(lstrEmail) <=0 Then
    bademail="Yes"
    else
    Response.Write(Len(lstrEmail)) & "<BR>"
    SendtoEmail = lstrEmail+"@company.com"
    Response.Write(SendtoEmail) & "<BR>"
    If cc ="Yes" then
	senderEmail = mail
	else
	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
	  
	  emailData.addNew
	  emailData("NewsID")=NGUID
	  emailData("UGUID")=senderUGUID
	  emailData("DS1")=additionalText
	  emailData("DS2")=SendtoEmail
	  emailData("DateTime")=dateTime
	  emailData("PageID")=DGUID	
	  emailData.update
	  emailData.close
	  
	
	set sysMail = Server.CreateObject("CDO.Message")
	sysMail.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.mail.company.com"
	sysMail.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
	sysMail.Configuration.Fields.Update
	sysMail.From = "TechOps_Connection_noreply@company.com"
	sysMail.To = SendtoEmail
	sysMail.cc = 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='http://subdomain.web.company.com/newsdetails.asp?DataID="&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
	'sysMail.Send
	
    end if

Open in new window

0
Comment
Question by:glstephens08
2 Comments
 
LVL 32

Accepted Solution

by:
Big Monty earned 500 total points
Comment Utility
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
0
 

Author Closing Comment

by:glstephens08
Comment Utility
Thanks, If p <> "" Then seems obvious now, but I was drawing a blank.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now