Outlook Email Security
The following code may not work properly if you have installed the Outlook E-mail Security Update. For additional information about this update, please see one of the following articles in the Microsoft Knowledge Base, depending on which version of Outlook you have:262631 OL2000: Information About the Outlook E-mail Security Update
262617 OL98: Information About the Outlook E-mail Security Update
If your fax does not appear to have proper
formatting, you may want to change your default e-mail editor to Microsoft
Word.
For more information
about the Outlook 2002 e-mail security features and how those features can
affect custom solutions, click the following article number to view the article in the Microsoft Knowledge Base:
290500
Description of the developer-related e-mail security features in Outlook 2002
Using the SendObject Method
The following examples use the sample database Northwind.mdb to show you how to create a macro and a Visual Basic procedure to fax a report using Microsoft Fax. However, you can also use an Access project (.adp) file for faxing information.When you use the SendObject method within Microsoft Access, you must have a messaging application (for example, Microsoft Outlook), that supports the Microsoft Mail Applications Programming Interface or MAPI.
If Outlook is running at the time you attempt to run the macro or code, you may receive an message similar to:
The file C:\Windows\Application Data\Microsoft\Outlook\Outlook.ost is in use and could not be accessed. Close any application that is using this file, and then try again.
If you see this message, close Outlook and run the code
again.If you have an electronic mail application that uses the Vendor Independent Mail (VIM) protocol and have installed and set up the dynamic-link library (Mapivim.dll) that converts MAPI mail messages to the VIM protocol, you can send Microsoft Access objects to the VIM mail application.
CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.
Creating a Macro
This example uses the SendObject action to fax the Catalog report to a single fax number.- Open the sample database Northwind.mdb.
- Open the Catalog report in Design view.
- On the File menu, click Page Setup.
- In the Page Setup dialog box, click the Page tab.
- In the Printer for Catalog option group, click Use Specific Printer, and then click the Printer button.
- In the Name list, select Microsoft Fax, and then click OK.
- In the Page Setup dialog box, click OK.
- Save the Catalog report and close it.
- Create the following macro named SendFax:NOTE: You do not need to include the hyphen "-" for this to work.
Macro Name Action ------------------------ SendFax SendObject Action Arguments ---------------------------------------------------------------- Object Type: Report Object Name: Catalog Output Format: Rich Text Format To: [Fax: +1 (###) ###-####] (where (###) ###-#### is the fax number)
- Run the macro to fax the report.
Creating a Visual Basic Procedure
NOTE: The sample code in this article uses Microsoft Data Access Objects. For this code to run properly, you must reference the Microsoft DAO 3.6 Object Library. To do so, click References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft DAO 3.6 Object Library check box is selected.This example shows you how to fax the Invoice report to each customer in the Customers table.
- Open the sample database Northwind.mdb.
- Open the Invoice report in Design view.
- On the File menu, click Page Setup.
- In the Page Setup dialog box, click the Page tab.
- In the Printer For Invoice option group, click Use Specific Printer, and then click the Printer button.
- In the Name list, select Microsoft Fax, and then click OK.
- In the Page Setup dialog box, click OK.
- Set the OnOpen property of the report to the following event procedure:
Me.Filter = strInvoiceWhere
- Save the report and close it.
- In the Database window, click Modules, and then click New.
- Type or paste the following code into the module.NOTE: If you plan to change this example and place the code behind a
form, leave the line "Public strInvoiceWhere As String" in a standard module.
Option Explicit Public strInvoiceWhere As String '**************************************************************** 'This function will walk through the Customers table and fax the 'Invoice report, which is filtered by the CustomerID field using 'MS Fax through the MS Access SendObject. ' 'This function assumes the Invoice report has the default printer 'set to MS Fax and the MS Fax driver is installed correctly. '**************************************************************** Function FaxInvoices() Dim dbsNorthwind As DAO.Database Dim rstCustomers As DAO.Recordset Set dbsNorthwind = CurrentDb() Set rstCustomers = dbsNorthwind.OpenRecordset("Customers", _ dbOpenDynaset) If MsgBox("Do you want to fax invoices" & Chr(13) & _ "to all customers using Microsoft Fax?", 4) = 6 Then With rstCustomers Do Until .EOF 'Create the Invoice report Filter 'used by the Report_Open event. strInvoiceWhere = "[CustomerID] = '" & ![CustomerID] & "'" DoCmd.SendObject acReport, "Invoice", acFormatRTF, _ "[fax: " & ![Fax] & "]", , , , , False .MoveNext Loop End With End If rstCustomers.Close End Function
- To test this function, type the following line in the
Immediate window, and then press ENTER:
? FaxInvoices()
To change the association for .rtf documents to WordPad, follow these steps:
- Click Start and then click Run.
- In the Open box, type Winfile, and then click OK.
- In File Manager, on the File menu, click Associate.
- In the Associate dialog box, under Files with Extension, type rtf.
- Click Browse
- Locate WordPad.Exe in C:\Program Files\Accessories, and then click OK.
- Quit File Manager.
- Click Start, point to Settings, and then click Control Panel.
- Double-click the Mail And Fax icon.
- In The following information services are set up in this profile box, select Microsoft Fax, and then click Properties.
- In the Time to Send box, select Specific Time, type a time in the Time box, and then click OK.
- Close the Mail And Fax box.