Board index » delphi » Send e-mail with attachment file

Send e-mail with attachment file

in my program:

I must send e-mail with attachment file.
I don't know, i can do.

e.g
e-mail and subject:
mailto:a...@asa.cxcx?subject=TEST

and how must be:
mail & attachment file

PLEASE HELP
Arek

 

Re:Send e-mail with attachment file


there are hundreds of components for dong this.

check out the net masters (fastnet) TSMTPClient (or something like that) in
the Delphi help.  it has properties for headers, body, and attatchements

--

"I like big butts and i cannot lie, you other brothers cant deny that when a
girl walks in with an itty bitty waist and a round thing in your face you
get ..." -- Donkey

Quote
"News" <webmas...@ze.slupsk.pl> wrote in message

news:agvfs0$erj$1@news.tpi.pl...
Quote
> in my program:

> I must send e-mail with attachment file.
> I don't know, i can do.

> e.g
> e-mail and subject:
> mailto:a...@asa.cxcx?subject=TEST

> and how must be:
> mail & attachment file

> PLEASE HELP
> Arek

Re:Send e-mail with attachment file


Quote
"News" <webmas...@ze.slupsk.pl> wrote in message

news:agvfs0$erj$1@news.tpi.pl...

Quote
> I must send e-mail with attachment file.
> I don't know, i can do.

See the two Internet component links at
http://www.bancoems.com/CompLangPascalDelphiMisc-MiniFAQ.htm

Re:Send e-mail with attachment file


Quote
> I must send e-mail with attachment file.
> I don't know, i can do.

> e.g
> e-mail and subject:
> mailto:a...@asa.cxcx?subject=TEST

> and how must be:
> mail & attachment file

To create a message in your mailing app from your Delphi code, you can:
1. create a message via default mailer using shell api:

uses ShellAPI;
var
  pCh: PChar;
begin
  pCh := 'mailto:ca...@msn.com?subject=your_subject&body=your_body';
  ShellExecute(0, 'open', pCh, nil, nil, SW_SHOWNORMAL);
end;

Some mailers supports the extended syntax with some usefule features. For
example, the MS Outlook supports the file attachment via ShellExecute.

var
  pCh: PChar;
begin
  pCh :=
'mailto:ca...@msn.com?subject=your_subject&body=your_body&file="c:\autoexec.
bat"';
  ShellExecute(0, 'open', pCh, nil, nil, SW_SHOWNORMAL);
end;

But other mailers don't supports this file attachment. You must convert a
texts which you want to place into subject or body - to change a spaces into
"%20".  On some builds of MS Windows the all characters from subject and
body will be trancated to small length or converted to lower case.

Create a message in Outlook using OLE:

const
  olMailItem = 0;
var
  Outlook, MailItem: OLEVariant;
begin
  try
    Outlook := GetActiveOleObject('Outlook.Application');
  except
    Outlook := CreateOleObject('Outlook.Application');
  end;

  MailItem := Outlook.CreateItem(olMailItem);
  MailItem.Recipients.Add('ca...@msn.com');
  MailItem.Subject := 'your subject';
  MailItem.Body := 'Welcome to my homepage: http://www.msn.com';
  MailItem.Attachments.Add('C:\Windows\Win.ini');
  MailItem.Send;

  Outlook := Unassigned;
end;

If you want to create a message in html-format, you can use the HTMLBody
property instead a Body. But note that this HTMLBody property is available
staring from Outlook 98 only.

BTW the email addy isn't mine...
I hope this helps...  I found it somewhere on the net and saved it for use
later...  Aren't you glad I did?

Other Threads