JPeg attachment on a plain text email

Giganews Newsgroups
Subject: JPeg attachment on a plain text email
Posted by:  Roger Webb (rwebb)
Date: Tue, 13 Apr 2004

Howdy,

Ive looked through the newsgroup looking ofr something like this...and all I
find is sending an attachment with an HTML style email.  I'm doing just a
plain Text Email with a JPG file attached as an attachment, not being shown,
that kinda thing.  However,  after the TIdAttachment.Create(...) line,
MailMessage.MessageParts.AttachmentCount = 0.  The email is sent, and I
receive the email, with the From stuff, to stuff, replyto stuff, and even
the body intact, except the attachment JPG File.  Below is the code.

MailMessage := TIdMessage.Create(nil);
MailMessage.From.Name := ...;
MailMessage.From.Address := ...;
MailMessage.Recipients.EmailAddresses := ...;
MailMessage.Subject := 'SUBJECT';
MailMessage.Body.Text := 'BODY TEXT';
MailMessage.Priority := mpHighest;
if FileExists('c:\temp.jpg') then
begin
  with TIdAttachment.Create(MailMessage.MessageParts, 'c:\temp.jpg') do
  begin
      FileName := 'temp.jpg';
      ContentType := GetMIMETypeFromFile('c:\temp.jpg');
  end;
  ShowMessage(IntToStr(MailMessage.MessageParts.AttachmentCount));
<---- This shows 0
end;

Thanks

- Roger

Replies