Email email using IDSMTP and IDMessage controls in C ++ Builder

xiaoxiao2021-03-06  59

The goal we need to be implemented is: Send an e-mail from DGYANYONG@sina.com and send the message to DGYANYONG@sohu.com and the DGYANYONG@msn.com. The content of the mail message is: Accessories for sending email messages using the IDSMTP and IDMessage controls in C Builder: temporarily do not consider

Add two Indy controls in Form1: IDSMTP (in the INDY Clients tab) IDMESSAGE Adds a MEMO1 in the form, a button button, double-click the Button1 button, add the following code:

Void __fastcall tform1 :: button1click (TOBJECT * Sender) {

IDMESSAGE1-> Recipients-> emaildresses = "DGYANYONG@sina.com"; // mail recipient's mailbox IDMESSAGE1-> from-> text = "DGYANYONG@163.com"; // Mail sender's mailbox IDMESSAGE1-> Subject = "Test Send Email"; // Email Title IDMessage1-> Body-> Add ("Send Email by IDSMTP and IDMessage Control in C Builder); // Mail Content IDMESSAGE1-> CClist-> EmailAddresses = "DGYANYONG @ sohu.com, DGYANYONG @ msn.com"; // message Cc address if (idsmtp1-> connect ()) {idsmtp1-> disconnect ();} idsmtp1-> authenticationType = atlogin; // login Server type selection IDSMTP1-> host = "smtp.163.com"; // SMTP server idsmtp1-> userid = "DGYANYONG"; // 163 mailbox user name idsmtp1-> password = "dgynyong"; // 163 mailbox Password idsmtp1-> port = 25; // port idsmtp1-> connect (); // Connect SMTP server if (IDSMTP1-> Authenticate ()) // User verification {MEMO1-> lines-> add ("login server authentication success ! "); Idsmtp1-> send (idMessage1); // Send Mail ME Mo1-> lines-> add ("Mail Send Success");} idsmtp1-> disconnect (); // Interrupt connection SMTP server}

The username and password of the above mailbox, the username and password of the 163 mailbox are fictitious, just do an example, the user can set according to their own needs.

转载请注明原文地址:https://www.9cbs.com/read-118051.html

New Post(0)