Solved

Listbox Help

Posted on 2006-10-24
5
185 Views
Last Modified: 2010-04-05
I have an email program that sends out emails to multiple people.

I have a listbox with a list of different emails to send to.  Then I have 2 other listboxes.  One will contain specific email addresses that won't be sent to.  The other will contain whole domains that won't be sent to.

For example:

Listbox with emails:         Specific Emails Listbox:         Domains Listbox:

blah1@yahoo.com           blah1@yahoo.com                @hotmail.com
blah2@yahoo.com
blah1@hotmail.com
blah2@hotmail.com

It should email to only blah2@yahoo.com because it has blah2@yahoo.com in the block list and the @hotmail.com addresses blocked.

Any ideas?

0
Comment
Question by:Grant Fullen
[X]
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
5 Comments
 
LVL 8

Accepted Solution

by:
RickJ earned 25 total points
ID: 17801196
Something like this...
var idx : integer ;

for idx := 0 to EmailListBox.Count - 1 do begin
  if (BlockedEmails.Items.Indexof(EmailListBox.Items[Idx]) = -1) and
     (BlockedDomains.Items.Indexof(Copy(EmailListBox.Items[Idx], Pos('@', EmailListBox.Items[Idx]), Length(EmailListBox.Items[Idx])) = -1)  then

  SendEmailProc ;
end ;

Dont have delphi in front of me, so sorry if any mistakes.
0
 

Author Comment

by:Grant Fullen
ID: 17806877
How do I use that to add to the recipients list?

Like:

EmailClient1.Recipients.Add("emails that didn't get blocked")
0
 
LVL 28

Expert Comment

by:TName
ID: 17807404
>How do I use that to add to the recipients list?

Simply add any EmailListBox item that has passed RickJ' two conditions:

 for idx := 0 to EmailListBox.Count - 1 do begin
    if (BlockedEmails.Items.Indexof(EmailListBox.Items[idx])=-1) and
      (BlockedDomains.Items.Indexof(Copy(EmailListBox.Items[idx],Pos('@', EmailListBox.Items[idx]), Length(EmailListBox.Items[idx])))=-1) then    //minor addition
           EmailClient1.Recipients.Add(EmailListBox.Items[idx]);  
 end;
0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 17808219
please tell me this isn't a spam bot
0
 

Author Comment

by:Grant Fullen
ID: 17808959
TheRealLoki the only spam here is your post.

Don't leave ignorant posts that aren't even related to the subject.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 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