🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Using Indy components to send email...but want to attach files

#1485
From: Remy Lebeau (TeamB)
Date: Fri, 05 Jan 2007 18:09
38 lines
2089 bytes
"dave" <dave@hhhh.net> wrote in message
news:459e5222$1@newsgroups.borland.com...

> I am using Indy components to send emails.  I would like to attach
anywhere from 0 to 7 files to these emails.

You need to use the TIdMessage::MessageParts collection for that.

> My current code looks like:

Use this code instead:

    IdMessage_Release_Notes->Clear();
    IdMessage_Release_Notes->From->Name = "Me";
    IdMessage_Release_Notes->From->Address = "ddd@hhhh.net";
    IdMessage_Release_Notes->Recipients->EMailAddresses =
"test@hhhh.net";
    IdMessage_Release_Notes->Subject = "Mail subject!!!!";
    IdMessage_Release_Notes->Body->Text = "Mail BODY Message Here";

    if( NumberOfAttachments > 0 )
    {
        for(int i = 0; i < NumberOfAttachments; ++i)
        {
            TIdAttachment *Attachment = new
TIdAttachment(IdMessage_Release_Notes->MessageParts, "FileName Here");
            Attachment->ContentType =
GetMimeTypeFrmFile(Attachment->FileName);
            // set other properties as needed ...
        }
        IdMessage_Release_Notes->ContentType = "multipart/mixed";
    }
    else
        IdMessage_Release_Notes->ContentType = "text/plain";


Gambit
Technical Details
Message-ID: <459e943c$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <459e5222$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,91daf0a133c0a136
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <459e5222$1@newsgroups.borland.com>
Subject: Re: Using Indy components to send email...but want to attach files
Date: Fri, 5 Jan 2007 10:09:56 -0800
Lines: 40
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.34.171
Message-ID: <459e943c$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1168020540 75.83.34.171 (5 Jan 2007 10:09:00 -0800)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail