Write email software with C ++ Builder

zhaozj2021-02-17  71

Two protocols closely related to e-mail are POP3 and SMTP, POP3 is an abbreviation for Post Protocol 3 for receiving email from the POP3 server, SMTP is an abbreviation of Simple Mail Transfer Protocol, which is used to send emails through the SMTP server. These two protocols themselves are very complicated, but C Builder introduced POP, SMTP control from NetManage, so we can do not depends on the mechanism of sending and receiving mail, as long as these controls can be selected, you can compile a C Builder send mail Program. The SMTP control is described below: SMTP control is located on the Internet page of the control bar, name: NMSMTP. The main attributes of SMTP are: Host property, used to specify the host name of the SMTP server. The port number used to specify the port number of the SMTP server, which is typically set to 25. UserId property is used to set the username when logging in to the SMTP server. Postmessage properties, this property is very important, you can see from the following: fromName is used to specify the name of the sender. FromAddress is used to specify an e-mail address of the sender. LocalProgram is used to specify the mail client used by the sender. The address of the toaddress recipient. Body mail body. Subject mail topic. SMTP control method: Connect function, used to log in to the SMTP server, before using this function, Host, port, userid, etc. must be set. Disconnect functions for disconnecting the connection to the SMTP server. The Sendmail function is used to send an email to the SMTP server. I know these, we can write the program.

New application, save the project as sendmail, add NMSMTP controls on Form1, and the Host property adds to the name of the SMTP server, such as "SMTP.YEAH.NET", UserId Attribute Add to the username of this mailbox application, Other properties maintain the default value; add 4 Label controls, set their Caption to: "Sender Name", "Recipient Address", "Mail Topics", and "Mail Text"; join 4 Edit controls, will Its NAME is set to: "Name1", "Address1", "Subject1" and "Body1"; a spetedButton control, caption is: "Send" (the above attribute is not included), the Click event code is: NMSMTP1-> Connect (); NMSMTP1-> PostMessageA-> FromName = Name1-> Text; NMSMTP1-> PostMessageA-> FromAddress = "superlink@yeah.net"; NMSMTP1-> PostMessageA-> ToAddress-> Add (Address1-> Text); NMSMTP1 -> PostMessageA-> Subject = Subject1-> Text; NMSMTP1-> PostMessageA-> Body-> Add (Body1-> Text); NMSMTP1-> PostMessageA-> LocalProgram = "SendMail"; NMSMTP1-> SendMail (); Application- > MessageBoxa ("Send Dress!", "Mail System", MB_OK; NMSMTP1-> disconnect (); completion! Some people can't help but ask: "Is it so simple?", It is so simple. However, NMSMTP controls have a lot of functions that are not listed here, and the NMPOP3 control can be used to write a program that receives mail. If you love C Builder friends, you can write an electronics such as Outlook Express, Foxmail. Mail software. = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - // __________ / lb / ___ outinn / _ [] _ ​​/ ____ // _________ / | () | / _ / http://outinn.yeah.net/ | ____ / - | __ | - / | Welcome To Visit Outinn! | __ | == | ___ | || | __ | - = - = - = - | _ || _ | = - fancy, Outinn@china.com

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

New Post(0)