e-mail yollama hakkında
Forum kuralları
Forum kurallarını okuyup, uyunuz!
Forum kurallarını okuyup, uyunuz!
e-mail yollama hakkında
arkadaşlar merhaba, delphi içinden her hangi bir mail adresine mail atmak istiyorum yapılmaş örnek kodlar varsa önerilerinizi bekliyorum arama yaptım çok çeşitli yöntemler anlatılmış içlerinden hangisini kullanabileceğimi şaşırmış durumdayım program delphi7 için olursa sevinirim.
İyi çalışmalar.
Burak BİTİKÇİ
İyi çalışmalar.
Burak BİTİKÇİ
procedure TForm1.Button1Click(Sender: TObject);
begin
IdMessage1.Recipients.EMailAddresses:='burakb44@hotmail.com';
IdMessage1.From.Address:='burakb44@hotmail.com';
IdMessage1.From.Name:='Burak';
IdMessage1.Sender.Address:='burakb44@gmail.com';
IdMessage1.Sender.Name:='Burak';
IdMessage1.ContentType:='text/html';
IdMessage1.Subject :='Konu yazılacak';
IdMessage1.Body.Clear;
IdMessage1.Body.Add('deneme satırı');
IdMessage1.MessageParts.Clear;
// TIdAttachment.Create(IdMessage1.MessageParts,'eklenecek dosya yolu');
IdSMTP1.Host:='smtp.gmail.com';
IdSMTP1.Username:= 'burakb44@gmail.com';
IdSMTP1.Password:= '........';
IdSMTP1.Connect;
IdSMTP1.Send(IdMessage1);
IdSMTP1.Disconnect;
end;
arkadaşlar yukarıdaki kodu çalıştırdığım zaman şöyle bir hata alıyorum.
'Project Projetc1.exe raised exception class EIdProtocolReplyError with message 5.7.0 Must issue a startttls command first d7sm115486wra'[/img]
begin
IdMessage1.Recipients.EMailAddresses:='burakb44@hotmail.com';
IdMessage1.From.Address:='burakb44@hotmail.com';
IdMessage1.From.Name:='Burak';
IdMessage1.Sender.Address:='burakb44@gmail.com';
IdMessage1.Sender.Name:='Burak';
IdMessage1.ContentType:='text/html';
IdMessage1.Subject :='Konu yazılacak';
IdMessage1.Body.Clear;
IdMessage1.Body.Add('deneme satırı');
IdMessage1.MessageParts.Clear;
// TIdAttachment.Create(IdMessage1.MessageParts,'eklenecek dosya yolu');
IdSMTP1.Host:='smtp.gmail.com';
IdSMTP1.Username:= 'burakb44@gmail.com';
IdSMTP1.Password:= '........';
IdSMTP1.Connect;
IdSMTP1.Send(IdMessage1);
IdSMTP1.Disconnect;
end;
arkadaşlar yukarıdaki kodu çalıştırdığım zaman şöyle bir hata alıyorum.
'Project Projetc1.exe raised exception class EIdProtocolReplyError with message 5.7.0 Must issue a startttls command first d7sm115486wra'[/img]
indy kullanarak oluşturduğum bir procedure. uzun zaman oldu, çalışıp çalışmadığını hatırlamıyorum.
Kod: Tümünü seç
procedure TForm1.Send_Mail(_UserName, _Password, _Host : String; _Port : Integer;
_AuthenticationType : TAuthenticationType;
_SenderEMailAdress, _To, _Cc, _Bcc, _Subject, _BodyText : String;
_Priority, _ReceiptRecipient : Byte; _Attachments : TStrings);
var
xSMTP : TIdSMTP;
xMessage : TIdMessage;
x : Integer;
begin
xSMTP := TIdSMTP.Create(Self);
try // SMTP Bileşenini oluştur ve Bağlan
with xSMTP do
begin
Username := Trim(_UserName);
Password := Trim(_Password);
Host := Trim(_Host);
Port := _Port;
AuthenticationType := _AuthenticationType;
Connect;
end;
except
ShowMessage('SMTP Sunucusuna Bağlantı Sağlanamadı..');
xSMTP.Free;
Exit;
end;
xMessage := TIdMessage.Create(Self);
try // Message Bileşenini Oluştur ve Maili Gönder
with xMessage do
begin
From.Text := Trim(_SenderEMailAdress);
ReplyTo.EMailAddresses := Trim(_SenderEMailAdress);
Recipients.EMailAddresses := Trim(_To);
CCList.EMailAddresses := Trim(_Cc);
BccList.EMailAddresses := Trim(_Bcc);
Subject := Trim(_Subject);
Body.Text := Trim(_BodyText);
Priority := TIdMessagePriority(_Priority);
if _ReceiptRecipient = 1 then
ReceiptRecipient.Text := Trim(From.Text)
else
ReceiptRecipient.Text := '';
if _Attachments.Count > 0 then
for x := 0 to _Attachments.Count - 1 do // Attachment ları ekle
TIdAttachment.Create(xMessage.MessageParts, _Attachments.strings[x]);
try
xSMTP.Send(xMessage);
finally
xSMTP.Disconnect;
end;
end;
xSMTP.Free;
xMessage.Free;
except
ShowMessage('Mail Gönderilemedi..');
xSMTP.Free;
xMessage.Free;
Exit;
end;
end;