Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Indy 9 SMTP inline attachments 1

Status
Not open for further replies.

mjrogers

Programmer
Jan 30, 2002
5
0
0
GB
I am trying to create an smtp message with an inline HTML document.

However the code I have produced appears to add HTML code as an attachment that I have to double click to open.

I am runnig Delphi 7 with Indy 9 components and reading the email from an Exchange server with Outlook 2003.

I have refined the code down to the following which contains a single form with a single button and a TIdSMTP and TIdMessage component.

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdMessageClient, IdSMTP, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
IdSMTP1: TIdSMTP;
IdMessage1: TIdMessage;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin

IdSMTP1.Host:='192.168.34.11'; // IP of SMTP relay
IdSMTP1.UseEhlo:=FALSE;

with IdMessage1 do
begin
From.Address:='mark@...';
Recipients.Add.Address:='mark.rogers@..';
Subject:='Test inline html email';
ContentDisposition:='inline';
ContentType:='text/html';
Body.Add('<HTML><B>Hello there</B></HTML>');
end;

IdSMTP1.Connect(10000);
IdSMTP1.Send(IdMessage1);
IdSMTP1.Disconnect();

end;

end.


Could someone please tell me where I am going wrong, or if what I am trying to do is impossible.

Many thanks


Mark Rogers


 
You have to send your message in proper MIME (Multipurpose Internet Mail Extensions) format.

As you've obviously seen, just sending a CGI HTML prologue won't cut it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top