![]() |
email mit Anhängen verschicken (Indys)
Liste der Anhänge anzeigen (Anzahl: 1)
hallo dp,
habe verzweifelt in der codelib etwas gesucht um emails aus einer anwendung mit anhang/anhängen zu versenden, habe es dann selbst (mit hilfe der indy beispiele) in die hand genommen: Es wird Indy 9 benötigt. man muss
Delphi-Quellcode:
einbinden
IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdMessageClient, IdSMTP
Delphi-Quellcode:
ich habe ein ausführliches Beispiel Programm angehängt
const
atNoLogin = 0; atSimpleLogin = 1; procedure Sendemail(sender_email, recipent_email, email_subject: string; email_text: tstrings; attachment_list: tstrings; //can be also attachment_list: tstringlist; smtp_username, smtp_password, smtp_host: string; const SmtpAuthType: integer = atSimpleLogin; smtp_port: integer = 25; email_priority: integer = 2); var idmsgSend: Tidmessage; smtp: Tidsmtp; i: integer; begin idmsgSend := Tidmessage.Create(nil); smtp := Tidsmtp.Create(nil); try with IdMsgSend do begin Body.Assign(email_text); From.Text := sender_email; ReplyTo.EMailAddresses := sender_email; Recipients.EMailAddresses := recipent_email; { To: header } Subject := email_subject; { Subject: header } Priority := TIdMessagePriority(email_priority); { Message Priority } CCList.EMailAddresses := ''; {CC} BccList.EMailAddresses := ''; {BBC} ReceiptRecipient.Text := ''; end; {attachment settings} if assigned(attachment_list) then for i := 0 to attachment_list.Count - 1 do TIdAttachment.Create(IdMsgSend.MessageParts, attachment_list.Strings[i]); {authentication settings} case SmtpAuthType of 0: SMTP.AuthenticationType := atNone; 1: SMTP.AuthenticationType := atLogin; {Simple Login} end; SMTP.Username := smtp_username; SMTP.Password := smtp_password; {General setup} SMTP.Host := smtp_host; SMTP.Port := smtp_port; {now we send the message} SMTP.Connect; try SMTP.Send(IdMsgSend); finally SMTP.Disconnect; end; finally idmsgSend.free; smtp.free; end; end; mfg smallsmoker [edit=TBx]Da der Nutzer Cluni eine mögliche Infizierung der BeispielExe gemeldet hat, wurde diese ausgeschnitten. Mfg, TBx[/edit] |
Re: email mit Anhängen verschicken (Indys)
Hey, also das Beispiel funktioniert bei mir weder mit einem googlemail.com, noch mit einem web.de, noch mit einem yahoo.de-Account. Getestet hab ich es auf 2 Rechnern in mehreren Netzen :(
P.S. Du solltest den Port auch zu den Parametern tun die veränderbar sind, da mehrere Mailing-Server unterschiedliche Ports nutzen! |
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:53 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