AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Delphi Problem mit Indy9/SMTP - HTML Mails mit Anhang
Thema durchsuchen
Ansicht
Themen-Optionen

Problem mit Indy9/SMTP - HTML Mails mit Anhang

Ein Thema von Adamo · begonnen am 15. Aug 2007 · letzter Beitrag vom 15. Aug 2007
Antwort Antwort
Adamo

Registriert seit: 5. Jul 2006
7 Beiträge
 
#1

Problem mit Indy9/SMTP - HTML Mails mit Anhang

  Alt 15. Aug 2007, 08:40
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:
.
.
  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;
Was ankommst. Sieht dann aber so aus beim HTML Mails mit Anhang:

--=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="urn:schemas-microsoft-comfficeffice" xmlns:w="urn:schemas-microsoft-comffice: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
  Mit Zitat antworten Zitat
Benutzerbild von Die Muhkuh
Die Muhkuh

Registriert seit: 21. Aug 2003
7.332 Beiträge
 
Delphi 2009 Professional
 
#2

Re: Problem mit Indy9/SMTP - HTML Mails mit Anhang

  Alt 15. Aug 2007, 08:44
Hi Adamo,
herzlich Willkommen in der Delphi-PRAXiS.

Es wäre noch gut zu wissen, wie du die TIdMessage "befüllst".
Manuel
  Mit Zitat antworten Zitat
Adamo

Registriert seit: 5. Jul 2006
7 Beiträge
 
#3

Re: Problem mit Indy9/SMTP - HTML Mails mit Anhang

  Alt 15. Aug 2007, 11:12
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;
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:03 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz