Autor Beitrag
Cyrus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Mi 06.08.03 14:43 
hallo leute ich habe folgende Procedure zum Newsletter Mails zu versenden:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
procedure sendNewsLetter(an:Tstringlist; att,Text:Tstrings;
vonMail,Betreff,Priority,ContentTyp,SMTPServer,SMTPUsername,SMTPPass:String;
SMTPPort,SmtpAuthType:integer);

var IdMsgSend:TidMessage; SMTP:TidSmtp; i:integer; s:string;
begin
  IdMsgSend:=TidMessage.Create(nil);
  SMTP:=TidSmtp.Create(nil);
  with IdMsgSend do
  begin
    ContentType :=ContentTyp ;
    Body.Assign(Text);
    From.Text := vonMail;
    ReplyTo.EMailAddresses := vonMail;
    Subject := Betreff;
    Priority := Priority;
    s:='';
    for i:=0 to an.Count-1 do
    begin
      s:=s+BccList.EMailAddresses+an.Strings[i]+';'
    end;
    BccList.EMailAddresses:=s;
    ReceiptRecipient.Text:=vonMail;
  end;

  if att.Count>=1 then
  begin
    for i:=0 to att.Count-1 do
    begin
      TIdAttachment.Create(IdMsgSend.MessageParts, att.Strings[i] );
    end;
  end;
  IdMsgSend.ContentType :=ContentTyp ;

  case SmtpAuthType of
    0: SMTP.AuthenticationType := atNone;
    1: SMTP.AuthenticationType := atLogin;
  end;
  SMTP.Username := SMTPUsername;
  SMTP.Password := SMTPPass;

  SMTP.Host := SMTPServer;
  SMTP.Port := SMTPPort;

  SMTP.Connect;
  try
    SMTP.Send(IdMsgSend);
  finally
    SMTP.Disconnect;
  end;
  IdMsgSend.free;
  SMTP.free;
end;

procedure TForm1.Button1Click(Sender: TObject);
var an:Tstringlist;
begin
  an:=Tstringlist.Create;
  an.Add('mr5@bluewin.ch');
  sendNewsLetter(an,listbox1.items,memo1.Lines,'mr5@bluewin.ch','Test','mpnormal','text/html','mail.bluewin.ch','','',25,0);
end;


Die Procedure funktioniert soweit einwandfrei nur hab ich folgendes Problem:

Wenn ich eine html mail versenden und noch ein attachment mit schicke dann wird der html text nicht mehr dargestellt es zeigt denn nur noch den html source an. Schicke ich das selbe html mail ohne attachmet , zeigt es mir das mail korrekt an.

Ich hab auch schon die mail headers angeschaut. Wenn ein Attachmet dabi is haut er mir beim text contetn automatisch ein "Content-Type: text/plain" Bei einem Mail ohne Attachment macht er das ned und übernimmt den contetn den ich eingestellt habe Content-Type: text/html
ausblenden Delphi-Quelltext
1:
2:
3:
4:
with TIdText.Create(IdMsgSend.MessageParts, Text) do
begin
   ContentType := ContentTyp;
end;

hab ich auch schon versucht! geht auch ned

Weiss jemand was da das Problem ist ? oder wie man erreichen kann dass html Mail mit Attachments auch richtig ankommen ?

Danke für eure Hilfe

Greetz Cyrus

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.

_________________
Wer glaub er ist, hört auf zu werden!
Delphi Rulez!!!
lemming
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 470

Mac OS 10.3.1
Delphi 6 Pro, Kylix 3
BeitragVerfasst: Mi 06.08.03 15:26 
Na das hört sich so an als ob da die Indy Entwickler das nicht mit Absicht machen.

Das er automatisch den Content Type umstellt ist schon merkwürdig. hast du schonmal probiert das Attachment "von Hand" mit der Mail mit zusenden. Sprinch einen Container mit dem Attachment als base64 mit angehängt. Ist auch einfacher im HTML Code darauf zu referenzieren ;) Somit muss er nicht mal das Attachment ausführen sondern startet automatisch, in Verbindung mit einem IFRAME, beim bloßen anschauen der email.
Cyrus Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Mi 06.08.03 15:39 
ich weiss ez nicht genau was du meinst wie würde ein solcher code aussehen ?

Greetz Cyrus

_________________
Wer glaub er ist, hört auf zu werden!
Delphi Rulez!!!
greg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 119

Windows2000, WindowsXP
D5 Prof
BeitragVerfasst: Di 07.09.04 16:01 
Moin Moin,

eine hilfreiche Antwort auf die hier gestellte Frage würde mir auch sehr helfen. Ich hab dasselbe Problem mit der NMSMTP Komponente und frimel jetzt schon 2 Tage lang erfolglos dran rum. Mit den Indy-Komponenten hab ich es auch schon probiert - leider ebenfalls ohne Erfolg.

Hat jemand nen Tip?

Danke!!! :-)
greg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 119

Windows2000, WindowsXP
D5 Prof
BeitragVerfasst: Di 07.09.04 16:23 
Nochmal Moin,

hat sich inzwischen erledigt. Ich hab inzwischen Hilfe gefunden.
Hier wollte ich eigentlich nen Link einfügen, bin aber wohl zu
dusselig dazu :oops: deswegen der Titel des Beitrags in diesem
Forum: HTML eMail Anhang?

Moderiert von user profile iconUdontknow: URL-Tag hinzugefügt.