Simple development of mail client programs (Zhou Yongsheng July 25, 2001 17:17)
After accustomed to the mail client program developed by others to send and receive the email, I always want to "break the rules", and get some novel stuffs to change the "taste". So I don't do it, I'm doing, I started to ponder how to use VB to design a simple mail client program. Below is some of the author's design ideas, only for your reference.
The basic steps for designing the program are: First, use Microsoft's MAPI interface to create one or several session in the mail program; after the session is established, the Client end can use the functionality provided by MAPI. The MAPI Control provided by Visual Basic is then designed to design MAIL to transmit and receive programs. When setting the email send section, we should first enter the Exchange setting interface, and select the "New" command to add a setup file; then select the "Internet Mail" setting item according to the prompt on the screen, and give the setup file For "888"; then we will set the way to access the Internet, enter the address of the mail server, set the transmission mode, etc. The parameter given here is the access method is Network, the address of the mail server is 168.160. .128.10, the transfer mode is set to Automatic.
After setting the relevant parameters of the mail, the next job is to use VB to formally start the design program. Open the operation interface of the VB program, create a new project with the New Project in the File menu item, then select the Standard.exe option in the pop-up interface. Next under the Project menu item, select the Property property option; under the General Option, change the Project Name to Send-email and change the FORM name and CAPTION to Send-email. Subsequently, add a mapimsSage Control on the screen, named MapIm1; add a mapising control, name Mapis1; add three TextBox Control, named Subject, Content, Addr. A Label is added before three TextBox, and Caption is changed to Subject, Content, Addr. Then we will set the various Property of MapIm1 as follows:
Download mail = truelogoui = truenewsession = falseusername = "888"
Here, set the Download Mail to True, which will be new Mail Download to Local when the program and the Mail Server are first connected. Set the Logoui to True, then when you enter an error in your program, the system will display a message box to let you enter the correct name. Since this program uses only a session, we set it to false. of course! If you have a lot of sessions to be built, you can set it to true. Fill in username is our newly added file name in Exchange; if you don't fill in content, the system will display some Message Box to enter a file. Next, add three Button Control, Logon, Logoff and Send on the FORM of the screen, and change CAPTION to LOG ON, LOG OFF, Send.
Add the following program code in logon_click (), this action is to log in to Mail Server.
Mapis1.signonmapim1.SessionId = ms1.sessionidmsgbox "Your ID IS" STR (MS1.SessionID) In this segment code, MS1.signon represents the login action. When logging in, because the MapIm1 Control's Download Mail property is set to True, you can see the Message Box display system on the screen is Download Mail. After the login is successful, the system will return a sessionID, fill the ID in the sessionID of MapIM1, so you can use this session to transfer E-mail.
Add the following program code in logoff_click (), this action is to leave the Mail Server.
Mapis1.signoff
Add the following program code in Send_Click (), this action is to make us email.
MAPIM1.ComposeMAPIM1.RecipDisplayName = addr.textMAPIM1.AddressResolveUI = TrueMAPIM1.MsgSubject = subject.text MAPIM1.MsgNoteText = content.textMAPIM1.SendMsgBox "successfully sending"
The compose command in this segment is mainly used to change the contents of RecipDisplayName, fill in the E-mail address, theme, and article content you want, respectively, and then send it with the Sendtext, followed by the send command.
Ok, here we have designed the send part of the email. Let's talk about how to design an email receiving part. According to the same method, in the VB interface, select New Project in the file option, and then select the "Standard.exe" option. Next under Project, select the Property property option; under the General option, change the Project Name to get-email and change the FORM name and CAPTION to GET-EMAIL. Below, let's add a mapimsSage Control on the screen, name to mapim1; add a mapisession control, name Mapis1; add three TextBox Control, named Subject, Content, IndexNo, change its CAPTION to Mail-Subject, Mail-Content, IndexNo; add a Label Control before TextBox, change the Caption to Subject, Content, IndexNo. Then then set the various Property of MapIM1 as follows:
Download mail = truelogoui = truenewsession = falseusername = "888"
Subsequently, we join a ButtonControl get-mail on the screen of the screen, change the caption to get mail. Establish a session like sending the Mail program section and MailServer.
Add the following program code in Get-mail_click (), this action is to receive the email.
MAPIM1.FetchForm1.Caption = MAPIM1. MsgCountMAPIM1.MsgIndex = CINT (indexno.text) subjec.Text = MM1.MsgNoteTextcontent.Text = MAPI1.MsgSubject wherein Fetch command is to take the letter in the system memory inbuffer. After taking the letter, we can beware of the number of letters by Msgcount Property, then you can use the MsgIndex settings to see which letter content, title, such that the message accepts the message is over.