🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Attachment missing from email

#928
From: Royce
Date: Thu, 06 Sep 2007 21:23
60 lines
2864 bytes
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote:
>
>"Royce Fessenden" <rfessenden@dmp.com> wrote in message
>news:46e03084$1@newsgroups.borland.com...
>
>> I can send an email but I can't get the attachment to be included.
>
>That is because you are putting the text in the wrong place and setting the
>wrong ContentType for the message.  Try this instead:
>
>    int TMainForm::TestFunction(void)
>    {
>        AnsiString FileToAttach = "C:\\Link\\Logs\\Logs.zip";
>
>        if( !FileExists(FileToAttach) )
>        {
>            Log->Lines->Add("File <" + FileToAttach + "> does not exist.");
>            return -1;
>        }
>
>        Log->Lines->Add("Attaching file " + FileToAttach);
>        TDMPCursor MyCursor(crHourGlass);
>
>        MailMessage->ContentType = "multipart/mixed";
>
>        TIdText *txt = new TIdText(MailMessage->MessageParts, NULL);
>        txt->Body->Add("With attachment.");
>        txt->ContentType = "text/plain";
>
>        TIdAttachment* LogFile = new
>TIdAttachment(MailMessage->MessageParts, FileToAttach);
>        LogFile->FileName = ExtractFileName(FileToAttach);
>        //LogFile->ContentType = GetMIMETypeFromFile(LogFile->FileName);
>        LogFile->ContentType = "application/zip";
>
>        SMTPClient->Connect();
>        try
>        {
>            SMTPClient->Send(MailMessage);
>        }
>        __finally
>        {
>            SMTPClient->Disconnect();
>        }
>
>        Log->Lines->Add("TestFunction Completed");
>        return 0;
>    }
>
>
>Gambit
>
>

Now I'm getting an Access violation at the line:  txt->Body->Add("With attachment.");

Body appears to be NULL, though the debug shows a valid address for the ->Add() method.  I tried several things, including replacing the NULL (second parameter) in the txt constructor with MailMessage->Body.  I can change the place where I get an error, but anything that will run and send an email does not send the attachment.  There's got to be something else I'm missing.

Royce 
Technical Details
Message-ID: <46e06fc0$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <46e03084$1@newsgroups.borland.com> <46e044e4$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,57b1f9f1187ccd3f
X-Google-Attributes: gid11508e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Royce" <rfessenden@dmp.com>
Sender: "Royce" <rfessenden@dmp.com>
Reply-To: "Royce" <rfessenden@dmp.com>
Subject: Re: Attachment missing from email
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 209.248.148.58     
References: <46e03084$1@newsgroups.borland.com> <46e044e4$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <46e06fc0$1@newsgroups.borland.com>
Date: 6 Sep 2007 14:23:12 -0700
X-Trace: newsgroups.borland.com 1189113792 207.105.83.66 (6 Sep 2007 14:23:12 -0700)
Lines: 60
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail