🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #1139

problem using INDY component when sending email

#1139
From: Van Wouwe Francois
Date: Tue, 27 Mar 2007 10:21
73 lines
3386 bytes
Hi,

When I use the SMTP component for sending email, the mail is send out, but 
when I close the form
I get an access violation at a given address, during the read of that 
address.
Herewith the code which I use
If someone can give me a hint of what the problem might be

private: // User declarations
    String maillist;

void __fastcall TF_Deelnemers::Email1Click(TObject *Sender)
{
    extern int RecId_club;
    extern String WORKDIR,PROGDIR;
    char buf[200];
    int taal;
    String temp,tornooi,tornooinaam,mailsettings;
    maillist="";

    maillist=DM->Q_CLUBS->FieldByName("email")->AsString;
    TIdEMailAddressItem *MAILLIST = IdMessage1->Sender;
    TIdEMailAddressList *TOLIST = new  TIdEMailAddressList(this);
    TIdEMailAddressList *BCCLIST = new  TIdEMailAddressList(this);
    ...
    mailsettings=String(buf);
    MAILLIST->Name=mailsettings;
    ...
    mailsettings=String(buf);
    MAILLIST->Address=mailsettings;
    TOLIST->EMailAddresses=maillist;
    IdMessage1->Recipients=TOLIST;
    IdMessage1->From=MAILLIST;
    IdMessage1->Sender=MAILLIST;
    maillist="francois.van.wouwe@skynet.be";
    BCCLIST->EMailAddresses=maillist;
    IdMessage1->BccList=BCCLIST;
    ...
            IdMessage1->Subject="Confirmation of inscription "+tornooinaam;
    IdMessage1->ContentType="text/plain";
    IdMessage1->Body->Clear();
    IdMessage1->Body->Add("Club = 
"+DM->Q_CLUBS->FieldByName("nr")->AsString+" 
"+DM->Q_CLUBS->FieldByName("naam")->AsString+"\n");
    ....
            IdMessage1->Body->Add("\nWith sporty greetings\n");
    ...
    mailsettings=String(buf);
    IdMessage1->Body->Add(mailsettings);
    GetPrivateProfileString("Email","SMTPHost","",buf,sizeof(buf),tornooi.c_str());
    mailsettings=String(buf);
    IdSMTP1->Host=mailsettings;
    GetPrivateProfileString("Email","Username","",buf,sizeof(buf),tornooi.c_str());
    mailsettings=String(buf);
    IdSMTP1->Username=mailsettings;
    if (!IdSMTP1->Connected())
        {
        IdSMTP1->Connect(-1);
        }
    IdSMTP1->Send(IdMessage1);
    IdSMTP1->Disconnect();
    delete TOLIST;
    delete BCCLIST;
    IdSMTP1->Destroying();
    IdMessage1->Destroying();
    ShowMessage("E-mail is verstuurd");
}

-- 
Kind regards

Francois Van Wouwe 
Technical Details
Message-ID: <4608f043$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!news.albasani.net!feeder06.uucp-net.de!reader.uucp.at!feeder08.uucp.at!feeder10.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,1c868e923aa6cca0,start
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Van Wouwe Francois" <francois.van.wouwe@skynet.be>
From: "Van Wouwe Francois" <francois.van.wouwe@skynet.be>
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: problem using INDY component when sending email
Date: Tue, 27 Mar 2007 12:21:53 +0200
Lines: 75
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 80.200.217.253
Message-ID: <4608f043$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1174990915 80.200.217.253 (27 Mar 2007 03:21:55 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!news.albasani.net!feeder06.uucp-net.de!reader.uucp.at!feeder08.uucp.at!feeder10.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail