TIdAttachmentFile and subject header did not work

Giganews Newsgroups
Subject: TIdAttachmentFile and subject header did not work
Posted by:  Alan T (alan_NO_SPAM_plt…@yahoo.com.au)
Date: Fri, 23 Jul 2010

Indy 10, D2007
I tried to attach files but the file is embedded as text in the email body
and also my email did not show up the subject in my OutLook.

emailMessage := TIdMessage.Create;
emailMessage.Clear;
emailMessage.ClearHeader;
emailMessage.ClearBody;
emailMessage.ContentType := 'text/html';
emailMessage.Subject := 'This is a dummy email';
emailMessage.Headers.Add(fEmailTitle);
emailMessage.Sender.Address := fSenderEmail;
emailMessage.From.Text := fSenderEmail;
emailMessage.ReplyTo.EMailAddresses := fReplyToEmail;

idtTextPart := TIdText.Create(emailMessage.MessageParts, nil);
idtTextPart.ContentType := 'text/plain';
idtTextPart.Body.Add(fEmailMessageList.Text);

TIdAttachmentFile.Create(emailMessage.MessageParts,
'C:\Temp\ClientReportService\reports\Sales(AllMarket)_Nat_All_All_Week_20100719.pdf');
fEmailClient.Connect();
fEmailClient.Send(emailMessage);

Replies