Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Oct : How to add attachment to SMTP email?
| Subject: | How to add attachment to SMTP email? |
| Posted by: | "Debby Beatty" (datapathdesi..@earthlink.net) |
| Date: | Tue, 17 Oct 2006 21:14:15 |
I can send an email. How do I add an attachment? Usually is an MS-Word
doc, sometimes txt file.
I have this working, but don't know what to do next:
procedure TMyEMail.SendMail(vFromAddress, vFromName, vToAddress,
vSubject, vBodyText, vLogFile, vAttachment:
string);
begin
IdMessage1.From.Address := vFromAddress;
IdMessage1.From.Name := vFromName;
IdMessage1.Recipients.EMailAddresses := vToAddress;
IdMessage1.Subject := vSubject;
IdMessage1.Body.Clear;
IdMessage1.Body.Add(vBodyText);
try
try
SMTP.Connect;
SMTP.Send(IdMessage1);
except on E:Exception do
Application.messagebox(Pchar(E.Message), 'ERROR: ' , 1);
end;
if vLogFile > ''
then WriteToLog(vFromAddress, vToAddress, vSubject, vLogFile);
finally
if SMTP.Connected
then SMTP.Disconnect;
end;
end;