Re: Problem with bcc

Giganews Newsgroups
Subject: Re: Problem with bcc
Posted by:  Remy Lebeau (TeamB) (no.spam@no.spam.com)
Date: Tue, 15 Mar 2005

"Robert Tulloch" <tulta…@attglobal.net> wrote in message
news:758BACED56C3E240tulta…@attglobal.net...

> I seem to have a problem in that the only mail that
> goes out under bcc is the last on ein the list.

You are not using it correctly to begin with.  BccList is a collection.  For
each iteration of the loop, you are adding a new item to the collection via
the Add() method.  But then you are completely ignoring the new item and
using the collection's EmailAddresses property to overwrite the contents of
the collection with items from a string.  Since your string only contains a
single recipient per iteration of the loop, the collection ends up with only
1 item in it.

> Doesn't this:
>
>    with BccList.Add do
>      BccList.EMailAddresses := WorkString;
>
> keep adding to the bcc list on each iteration?

No.  Assigning the EmailAddresses property erases the current items from the
collection and then adds new items that are parsed from the string.  To do
what you are asking for, your code needs to be more like the following
instead:

    var
        Item: TListItem;
        Recip: TIdEmailAddressItem;
    begin
        //...
        for I := 0 to RecipientListView.Items.Count-1 do
        begin
            Item := RecipientListView.Items[I];
            Recip := BccList.Add;
            Recip.Name := '"Id No. ' + Item.Caption + '  ' +
Item.SubItems[0] + '"';
            Recip.Address := Item.SubItems[1];
        end;
        //...
    end;

Gambit

Replies

In response to

Problem with bcc posted by Robert Tulloch on Tue, 15 Mar 2005