Solved

Listbox Help

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10, MySQL Query 4 143
FMX StringGrid1->Canvas->FillRect Problem 3 153
FMX and jaudiotracker playing memory stream 29 79
Wincontrol not (correctly) drawn 15 38
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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