?
Solved

Listbox Help

Posted on 2006-10-24
5
Medium Priority
?
188 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 100 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

762 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