Kod: Tümünü seç
procedure Mail_Gonder_Ekli(GonderilecekMesaj,
MailKimeGidecekAcik, MailKimeGidecekBilgi, MailKimeGidecekGizli,
MesajBasligi, DosyaYolu: string);
begin
Application.ProcessMessages;
with IdMsgSend do
begin
Application.ProcessMessages;
Body.Text := GonderilecekMesaj;
From.Text := UserEmail;
ReplyTo.EMailAddresses := UserEmail;
Recipients.EMailAddresses := MailKimeGidecekAcik;
Subject := MesajBasligi;
Priority := TIdMessagePriority(0); { Message Priority }
CCList.EMailAddresses := MailKimeGidecekBilgi; {CC}
BccList.EMailAddresses := MailKimeGidecekGizli; {BBC}
Application.ProcessMessages;
TIdAttachmentFile.Create(IdMsgSend.MessageParts, DosyaYolu);
ResetAttachmentListView;
end;
{authentication settings}
case SmtpAuthType of
0: SMTP.AuthType := atNone;
1: SMTP.AuthType := atDefault; {Simple Login}
end;
SMTP.Username := SmtpServerUser;
SMTP.Password := SmtpServerPassword;
{General setup}
SMTP.Host := SmtpServerName;
SMTP.Port := SmtpServerPort;
{now we send the message}
SMTP.Connect;
try
Application.ProcessMessages;
SMTP.Send(IdMsgSend);
finally
SMTP.Disconnect;
end;
Application.MessageBox('Mesajınız Başarılı Bir Şekilde Gönderildi.', 'Bilgi', MB_ICONINFORMATION);
end;
procedure ResetAttachmentListView;
var li: TListItem;
idx: Integer;
begin
IdMsgSend.Encoding := meDefault;
IdMsgSend.ContentType := 'multipart/mixed';
IdMsgSend.ContentDisposition := 'attachment';
lvFiles.Items.Clear;
for idx := 0 to Pred(IdMsgSend.MessageParts.Count) do
begin
li := lvFiles.Items.Add;
if IdMsgSend.MessageParts.Items[idx] is TIdAttachmentFile then
begin
li.ImageIndex := 0;
li.Caption := TIdAttachmentFile(IdMsgSend.MessageParts.Items[idx]).Filename;
li.SubItems.Add(TIdAttachmentFile(IdMsgSend.MessageParts.Items[idx]).ContentType);
end
else
begin
li.ImageIndex := 1;
li.Caption := IdMsgSend.MessageParts.Items[idx].ContentType;
end;
end;
end;
Arkadaşlar yukarıdaki kodlarla indy bileşenleri ile mail gönderiyorum.Ancak yapamadığım olay şu mail ya HTML olarak gidiyor, yada Attachment.Mailimin düz bir yazı olarak girmesini istemiyorum.ContentType := 'text/html'; olarak yaparsam HTML kodları içeren şekilli yazıyı gönderiyorum.Sorun yok ama bu sefer ek dosya gitmiyor daha doğrusu eki de text olarak gönderiyor. Eğer ContentType := 'multipart/mixed'; yaparsam sorun yok ekli dosyayı gönderiyor ama bu seferde html kodları değerlendirmiyor olduğu gibi düz yazı olarak gidiyor.
Yani bir maili hem HTML olarak gönderip birde buna attachment yapamıyormuyuz.
Bilgisi olan varsa yardım etsin lütfen.
İyi çalışmalar....