The first thing you'll want to experiment with is sending a standard text note using the MAIL API. You can accomplish this with the following routine which automates the process of logging on, establishing the recipient structure, attachment structure, etc. This function assumes that you've got the constants and API declarations that are included with this paper and that they are loaded in the current database.
Function SendMailBasic () 'This function simply calls the MAPI functions 'to prompt the user for login, addressee information, etc. ' 'This is the most basic of mail-enabling routines because 'we're allowing MAPI to handle all aspects of the creation 'of the message. On Error GoTo SendMailBasicErr Dim iStatus As Long Dim tMessage As MAPIMessage Dim tRecips As MAPIRecip Dim tFiles As MAPIFile 'first, logon to MAPI iStatus = MAPILogon(0&, "", "", MAPI_LOGON_UI, 0&, gMAPISession) If iStatus <> SUCCESS_SUCCESS Then MsgBox "Unable to logon to MAPI" Exit Function End If 'next, call MAPI to display the dialog box to send a note 'by specifying MAPI_DIALOG, the result is the presentation of 'the standard send note dialog box. iStatus = MAPISENDMAIL(gMAPISession, 0&, tMessage, tRecips, tFiles, MAPI_DIALOG, 0&) If iStatus <> SUCCESS_SUCCESS Then MsgBox "Unable to send message" Exit Function End If 'logoff of mail, release our session iStatus = MAPILogoff(gMAPISession, 0, 0, 0) Exit Function SendMailBasicErr: MsgBox Error$ Exit Function End Function
This function completes all the necessary steps to send a basic e-mail message from within an Microsoft Access application. First, logon to MAPI as we've explained. If an error is encountered, let the user know about a problem and exit the function.
Next, make the call to MAPI to display the dialog box and prompt the user for the various information items. Since we've told MAPI that it's responsible for the user interface for the message, it will also send out the message after the user has completed the work.
Finally, we logoff from the MAPI session, clearing our session ID. At the beginning of the function, we've established a basic error handler which simply displays the Microsoft Access error message and exits the function.
This will provide the common dialog box that your users are familiar with. It will provide the interface that they know, including the address book, options dialog box and other items that are used to create or manage the message.