![]() |
Problem mit Indy9/SMTP - HTML Mails mit Anhang
Ich habe ein Problem beim verschicken von HTML Mails mit Anhang.
Ich hole sie über POP3 ab, speichere die Mail in IdMessage und schicke sie dann über SMTP weiter. Der Code recht simpel:
Delphi-Quellcode:
Was ankommst. Sieht dann aber so aus beim HTML Mails mit Anhang:
.
. POP.Connect; POP.Retrieve(0, Msg); . . IdSMTP1.AuthenticationType := atLogin; {Simple Login} IdSMTP1.Username := SmtpServerUser; IdSMTP1.Password := SmtpServerPassword; IdSMTP1.Host := SmtpServerName; IdSMTP1.Port := SmtpServerPort; Msg.Recipients.EMailAddresses := '****@***.de'; IdSMTP1.Connect; try IdSMTP1.Send(Msg); finally IdSMTP1.Disconnect; end; --=oreStuf_2altzzz1234sadvnqw3nerasdf Content-Type: text/plain; charset=s-ascii" Content-Transfer-Encoding: quoted-printable Testststststts#+ Askj Adlksj Asdlkjh# --=oreStuf_2altzzz1234sadvnqw3nerasdf Content-Type: text/html; charset=s-ascii" Content-Transfer-Encoding: quoted-printable <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"> <head> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"> <meta name=Generator content="Microsoft Word 12 (filtered medium)"> <style> <!-- /* Font Definitions */ @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri","sans-serif";} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed |
Re: Problem mit Indy9/SMTP - HTML Mails mit Anhang
Hi Adamo,
herzlich Willkommen in der Delphi-PRAXiS. :dp: Es wäre noch gut zu wissen, wie du die TIdMessage "befüllst". |
Re: Problem mit Indy9/SMTP - HTML Mails mit Anhang
Ich verwende die Demo von den Indy Komponenten.
Diese Zeile holt die Ursprugsmail vom Server und legt diese in IdMessage ab, sofern ich das richtig sehe. 'POP.Retrieve(lvHeaders.Selected.Index + 1, Msg);' Dann wird die so gefüllte 'Msg'(vom Typ IdMessage) 1 zu 1 über SMTP weiterversendet an einen bestimmten Empfänger. Diese kommt dann aber so wie oben gezeigt an.
Delphi-Quellcode:
procedure TfrmMain.RetrieveExecute(Sender: TObject);
var stTemp: string; intIndex: Integer; li: TListItem; begin stTemp := Statusbar1.Panels[1].text; if lvHeaders.Selected = nil then begin Exit; end; //initialise Showbusy(true); Msg.Clear; Memo1.Clear; lvMessageParts.Items.Clear; From.Caption := ''; Cc.Caption := ''; Subject.Caption := ''; Date.Caption := ''; Receipt.Caption := ''; Organization.Caption := ''; Priority.Caption := ''; pnlAttachments.visible := false; //get message and put into MSG ShowStatus('Retrieving message "' + lvHeaders.Selected.SubItems.Strings[3] + '"'); POP.Retrieve(lvHeaders.Selected.Index + 1, Msg); statusbar1.Panels[0].text := lvHeaders.Selected.SubItems.Strings[3]; //Setup fields on screen from MSG From.Caption := Msg.From.Text; Recipients.Caption := Msg.Recipients.EmailAddresses; Cc.Caption := Msg.CCList.EMailAddresses; Subject.Caption := Msg.Subject; Date.Caption := FormatDateTime('dd mmm yyyy hh:mm:ss', Msg.Date); Receipt.Caption := Msg.ReceiptRecipient.Text; Organization.Caption := Msg.Organization; Priority.Caption := IntToStr(Ord(Msg.Priority) + 1); //Setup attachments list ShowStatus('Decoding attachments (' + IntToStr(Msg.MessageParts.Count) + ')'); for intIndex := 0 to Pred(Msg.MessageParts.Count) do begin if (Msg.MessageParts.Items[intIndex] is TIdAttachment) then begin //general attachment pnlAttachments.visible := true; li := lvMessageParts.Items.Add; li.ImageIndex := 8; li.Caption := TIdAttachment(Msg.MessageParts.Items[intIndex]).Filename; li.SubItems.Add(TIdAttachment(Msg.MessageParts.Items[intIndex]).ContentType); end else begin //body text if Msg.MessageParts.Items[intIndex] is TIdText then begin Memo1.Lines.Clear; Memo1.Lines.AddStrings(TIdText(Msg.MessageParts.Items[intIndex]).Body); end end; end; ShowStatus(stTemp); Showbusy(false); end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:13 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz