🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Attachment missing from email

#926
From: Remy Lebeau (TeamB)
Date: Thu, 06 Sep 2007 18:19
50 lines
2300 bytes
"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
Technical Details
Message-ID: <46e044e4$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>

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: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <46e03084$1@newsgroups.borland.com>
Subject: Re: Attachment missing from email
Date: Thu, 6 Sep 2007 11:19:24 -0700
Lines: 52
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.83.29.61
Message-ID: <46e044e4$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1189102820 75.83.29.61 (6 Sep 2007 11:20:20 -0700)
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