Einzelnen Beitrag anzeigen

Benutzerbild von CTV
CTV

Registriert seit: 20. Jan 2004
Ort: Zug CH
83 Beiträge
 
Delphi 7 Professional
 
#45

Re: Email per AUTH SMTP versenden

  Alt 26. Okt 2004, 01:18
--------------------------------------------------------------------------------
E-Mail senden mit Indy
--------------------------------------------------------------------------------
Beschreibung Die Porcedure erklährt sich von alleine
Delphi-Quellcode:
 
 
Source procedure sendNewsLetter(an: Tstringlist; att, Text: Tstrings;
  vonMail, Betreff, Priority, CT, 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
    ContentTyp := CT;
    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;

  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;
ich hab auch ma sowas gecodet vielleicht hilft dir das weiter

greetz Cyrus
Wer glaub er ist, hört auf zu werden!
Delphi Rulez!!!
  Mit Zitat antworten Zitat