Solved

Listbox Help

Posted on 2006-10-24
5
182 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

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