![]() |
|
#1
|
|||
|
|||
|
Hi all
Just wondering how i would attach files and the like, to email messages in indy 10. I understand how to do it in indy 9, but now the code is different. -aht203 |
|
#2
|
|||
|
|||
|
HI,
this is a piece of code from a software of mine :') you need a TIdMessage, a TListView called "lv_email", an TOpenDialog called "OpenDialog1" and a TButton called "Button1" IMPORTANT: Remember to add "IdAttachmentFile" to your uses because it won't be added automatically :'p PS: indy should have an example of email client. I don't remember if it's only for indy 9 or also for indy 10. Accept if it helped :'D [delphi] unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, IdAttachmentFile, IdBaseComponent, IdMessage; type TForm1 = class(TForm) IdMessage1: TIdMessage; lv_email: TListView; OpenDialog1: TOpenDialog; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var li: TListItem; i: Integer; begin try if OpenDialog1.Execute then TIdAttachmentFile.Create(IdMessage1.MessageParts, OpenDialog1.FileName); lv_email.Items.Clear; for i := 0 to IdMessage1.MessageParts.Count - 1 do begin li := lv_email.Items.Add; if IdMessage1.MessageParts.Items[i] is TIdAttachmentFile then li.Caption := TIdAttachmentFile(IdMessage1.MessageParts.Items[i]).Filename; end; except on E : Exception do MessageDlg('Error', mtError, [mbOK], 0); end; end; end. [/delphi] __________________________________________________ _______ Delphi 6 Personal :'( Expert Points = 7 ;') I live in Torino :'D
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|