Delphi Mail Gönderme HTML ve Attachment

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
Kullanıcı avatarı
NewMember
Üye
Mesajlar: 990
Kayıt: 29 Haz 2005 06:57
Konum: Bursa

Delphi Mail Gönderme HTML ve Attachment

Mesaj gönderen NewMember »

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....
Kullanıcı avatarı
csunguray
Üye
Mesajlar: 855
Kayıt: 09 Ara 2006 05:08
Konum: Adana
İletişim:

Re: Delphi Mail Gönderme HTML ve Attachment

Mesaj gönderen csunguray »

C. Sunguray
csunguray at netbilisim.kom
Net Bilişim Hizmetleri

Sıradan her programcı bilgisayarın anlayabileceği kodlar yazabilir.
Sadece iyi programcılar insanların da anlayabileceği kodlar yazarlar.
Martin Fowler (http://martinfowler.com/)
Cevapla