With VB5.0 Design E-Mail Program Foreword With the development of computer network, the time of information transmission between people and people is much shortened. Many files are transmitted in the form of an email; people usually used by computers, more or less use E-mail to transfer information. This article will show you how to design the Mail program with Microsoft Mapi (Messaging Application Program Interface). Firstly, the MAPISession Control and Mapimestage Control provided by Visual Basic, then use the E-mail programs provided by Microsoft Internet Explorer 3.0 to test the correctness of the programming MAPI interface is a series provided by Microsoft. For users to develop Mail, Scheduling, Bulletin Board, a programming interface of the Communication program. When using the MAPI design program, you must first create one or several sessions between the program and the MAPI; after the session is established, the Client end can use the functionality provided by MAPI. MAPI features mainly divided into three parts: Address Books, Transport and Message Store. Address books is primarily responsible for setting up E-mail type, protocol; Transport is responsible for functions such as sending and reception of documents; Message Store is responsible for sending information such as information. Said so much, the Mapi interface seems to be terrible. However, Visual Basic provides the Mapise Control and MAPIMESSAGE CONTROL that has been packaged into many complex parts into simple properties and features, we only need to make some simple settings for Property and functions, you can write a Mail send and receive program. The following author will use Visual Basic's Mapicontrol to design Mail to transfer and receive programs. E-MAIL Send Some Step 1: Set the Exchange All parameters to enter the Exchange system, select the new setup file; the required information service is displayed, select Internet Mail. Set the name of the setting file to TEST. The screen will display two options, you can choose to connect in a modem method or in a NetWork. The author uses the Internet line, so choose Network; if you are using the PPP dial-up method to connect to the Internet, you should select Modem. After selecting NetWork, Exchange requires us to enter Mail Server's IP Address. The Mail Server address of the author now is 202.96.128.111, which is set to this address in this program. Then the TRANSFORM MESSAGE mode is set to Automatic, so when we connect to Mail Server, the new information will automatically download to the Local. Next, set the Email Address, Full Name, Password, Download Path, step by step, which completes the settings of the Exchange parameters. Step 2: Programming Select NewProject to create a new project in the file option, and you will see many options on the screen, such as ActiveX Document.exe, ActiveX Document.dll, ActiveX.exe, ActiveX Control, etc. Select Standard.exe when you are.
Under Project, select the Property property option; under the General Option, change the Project Name to Email-Send and change the FORM name and CAPTION to email-send. Add MAPIMESSAGECONTROL to the screen on the screen, named MapIm1; add a mapisession control, named mapis1; add three TextBox Control, named Subject, Content, Addr. A Label is added before three TextBox, and Caption is changed to Subject, Content, Addr. To facilitate the reader to understand each other, the following table explains: (TextBox) Name ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------- Subject (Input Letter Title) Content (Enter Letter Content) AddR (Enter the address to be transmitted) (Label) CAPTION ----- ----------------------------------------- Subject (Input Letter Title Tips) Content (Input Letter Content Tips) AddR (Enter letter to send location prompt) Set the Property of MapIM1 as follows: Download mail = truelogoui = trueWession = falseuserName = "test" Here to set Download Mail to True, when procedures and mail When Server is first connected, the new Mail Download to Local is used. 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. Add three Button Control, Logon, Logoff and Send on the FORM of the screen, and change CAPTION to LOG ON, LOG OFF, Send. (Button) Name CAPTION --------------------------------------------- ---------- Logon (execute login command) logOffSend (execution send mail command) 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) ms1.signon is a 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 us MailServer.
Mapis1.signoff adds the following program code in Send_Click (), this action is to send us email. MAPIM1.ComposeMAPIM1.RecipDisplayName = addr.textMAPIM1.AddressResolveUI = TrueMAPIM1.MsgSubject = subject.text MAPIM1.MsgNoteText = content.textMAPIM1.SendMsgBox "you successful" The main purpose Compose command, that allows you to change the contents of RecipDisplayName of the required The transferred E-mail address, theme, the article contents are filled in RecipdisPlayName, MsgSubject, MsgnoteText, and then send it with the send command. Step 3: Perform the Email-Send program designed above with the IE 3.0 Mail program test. Fill in "Send Test" in Subject Textbox, fill in gzsydici@public1.guangzhou.gd.cn in Address Textbox, enter the content you want to transfer in Content TextBox: "Hello everyone! This is a letter test", then Press the transfer. This letter will be sent! Perform IE 3.0 Select Receive Letters and select Read Mail in the mail option. We will see a letter titled "Sending Test" in Inbox, then we look at its content, yes! That is the test letter we just sent. E-MAIL Receive Section Step 1: Programming Select New Project to establish a new project in the file option. See a number of options on the screen, such as ActiveX Document.exe, ActiveX Document.dll, ActiveX.exe, ActiveX Control, etc. At this time, Standard.exe is selected. Next, under Project, select the Property property option; under the General option, change the Project Name to Email-Get, and change the FORM name and CAPTION to email-get. Add a MAPIMESSAGE Control on the screen, name MapIm1; add a mapisession control, named mapis1; add three TextBox Control, named Subject, Content, IndexNo, change its CAPTION to Mail-Subject, Mail-content, indexno; and add a Label Control before TextBox, change the Caption to Subject, Content, IndexNo. Set the property of MapIM1 as follows: Download mail = truelogoui = truenewsession = falseuserName = "TEST" These setting principles are as designed to send the Mail program part. Next, a Button Control get-mail is added to the FORM of the screen, and CAPTION is changed to Get Mail. Establish a session like sending the Mail program section and Mail Server. Add the following program code in Get-mail_click (), this action is to receive email.