Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 07-22-2006, 10:32 PM
aht203 aht203 is offline
Senior Member
 
Join Date: Mar 2006
Posts: 146
Default Sending email attachments in indy 10

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
Reply With Quote
  #2  
Old 07-23-2006, 07:37 AM
Italy Italy is offline
Senior Member
 
Join Date: Nov 2002
Posts: 528
Default RE: Sending email attachments in indy 10

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

Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 05:46 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.