Einzelnen Beitrag anzeigen

ByTheTime

Registriert seit: 24. Sep 2011
Ort: Frankfurt
297 Beiträge
 
Delphi XE2 Architect
 
#4

AW: [INDY] TIdSMTP und Anhänge

  Alt 24. Dez 2013, 11:39
Okay, nach viel gesuche, ging es nun doch relativ schnell

Delphi-Quellcode:
    with IdMessage do
      begin
        ContentType := 'multipart/*';

        From.Address := ASenderAdress;
        From.Name := ASenderName;

        Subject := ASubject;

        Recipients.EMailAddresses := ARecipients;

        IdText := TIdText.Create(MessageParts, TStringList.Create);
        IdText.ContentType := 'text/plain';
        IdText.Body.Text := ABody;
      end;

      if Trim(Files) <> EmptyStr then
      begin
        try
          IdAttachmentList := TStringList.Create;
          IdAttachmentList.CommaText := Files;

          for i := 0 to IdAttachmentList.Count - 1 do
          begin
            IdMessage.IsEncoded := True;

            IdAttachment := TIdAttachmentFile.Create(IdMessage.MessageParts,
              IdAttachmentList.Strings[i]);
            IdAttachment.FileName :=
              ExtractFileName(IdAttachmentList.Strings[i]);
            IdAttachment.ContentType := 'application/octet-stream';
            IdAttachment.OpenLoadStream;
            IdAttachment.CloseLoadStream;
          end;
        finally
          IdAttachmentList.Free;
        end;
      end;
Hierund hier gab es noch was schönes

Für Verbesserungen, Optimierungen und Vorschläge bin ich gerne offen

Gruß,
Lukas
Lukas

Geändert von ByTheTime (24. Dez 2013 um 11:40 Uhr) Grund: Code formatiert ;)
  Mit Zitat antworten Zitat