🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Attachment missing from email

#925
From: Royce Fessenden
Date: Thu, 06 Sep 2007 16:53
42 lines
2180 bytes
I am trying to add the ability to email error logs from the help screen of an application.  I have a simple test form with a TIdSMTP component and a TIdMessage component.  I can send an email but I can't get the attachment to be included.  I'm using the following test code in Borland C++ Builder 6, using Indy 9.0.50.

int TMainForm::TestFunction(void)
{
  AnsiString FileToAttach = "C:\\Link\\Logs\\Logs.zip";
  if (FileExists(FileToAttach))
  {
    Log->Lines->Add("Attaching file " + FileToAttach);
  }
  else
  {
    Log->Lines->Add("File <" + FileToAttach + "> does not exist.");
  }
  TDMPCursor MyCursor(crHourGlass);

  // MailMessage is a TIdMessage component on the main form.
  MailMessage->ContentType = "multipart/related; type=\"text/html\"";
  MailMessage->Body->Add("With attachment.");
  TIdAttachment* LogFile = new  TIdAttachment(MailMessage->MessageParts, FileToAttach);
  LogFile->FileName = FileToAttach;
  //LogFile->ContentType = GetMIMETypeFromFile(LogFile->FileName);
  LogFile->ContentType = "application/zip";

  try
  {
    // SMTPClient is a TIdSMTP component on the main form.
    SMTPClient->Connect();
    SMTPClient->Send(MailMessage);
  }
  __finally
  {
    SMTPClient->Disconnect();
  }

  Log->Lines->Add("TestFunction Completed: " + AnsiString(""));
  return 0;
}

What am I missing?

Royce
Technical Details
Message-ID: <46e03084$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,57b1f9f1187ccd3f,start
X-Google-Attributes: gid11508e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Royce Fessenden" <rfessenden@dmp.com>
Sender: "Royce Fessenden" <rfessenden@dmp.com>
Reply-To: "Royce Fessenden" <rfessenden@dmp.com>
Subject: Attachment missing from email
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 209.248.148.58     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <46e03084$1@newsgroups.borland.com>
Date: 6 Sep 2007 09:53:24 -0700
X-Trace: newsgroups.borland.com 1189097604 207.105.83.66 (6 Sep 2007 09:53:24 -0700)
Lines: 42
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail