Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Nov : Send mail with TIMAP4
| Subject: | Send mail with TIMAP4 |
| Posted by: | "Arni Thor Erlendsson" (arnith..@skyrr.is) |
| Date: | Mon, 19 Nov 2007 10:46:19 |
Hi,
I'm trying to send mail trough IMAP server.
This is what I'm doing (this code works with TIdSMTP):
Please help me.
Indy version: 10.1.5
procedure TForm2.Button1Click(Sender: TObject);
var
IdIMAP: TIdIMAP4;
IdMessage: TIdMessage;
IdEmAddrItm: TIdEmailAddressItem;
begin
IdIMAP := TIdIMAP4.Create(nil);
IdMessage := TIdMessage.Create(nil);
IdMessage.From.Name := 'My name;
IdMessage.From.Address := 'me@somehost.com';
IdMessage.Sender.Name := 'My name';
IdMessage.Sender.Address := 'me@somehost.com';
IdMessage.Subject := 'This is the subject';
IdMessage.Body.text := 'This is the body';
IdEmAddrItm := IdMessage.BccList.Add;
IdEmAddrItm.Name := 'Your name';
IdEmAddrItm.Address := 'somone@somewhere.com';
IdIMAP.Host := 'mail.somehost.com';
IdIMAP.Username := 'user';
IdIMAP.Password := 'password;
IdIMAP.Connect(true);
try
IdIMAP.SendMsg(IdMessage);
IdIMAP.Disconnect; // Unexpected: Non-last response line (i.e. a data
line) did not start with a *, offending line: From: BAD No such command as
""Arni"
except on e: exception do
memo1.lines.add(e.message);
end;
IdMessage.free;
IdIMAP.free;
end;