SendObject Action

Description

You can use the SendObject action to include the specified Microsoft Access datasheet, form, report, or module in an electronic mail message, where it can be viewed and forwarded. You can include objects in Microsoft Excel 97 (*.xls), MS-DOS text (*.txt), rich-text (*.rtf), or HTML (*.html) format in messages for Microsoft Exchange, Microsoft Mail, Microsoft Windows for Workgroups mail, or another electronic mail application that uses the Microsoft Mail Applications Programming Interface (MAPI).

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.

Setting

The SendObject action has the following arguments.

Action argument

Description

Object Type

The type of object to include in the mail message. Click Table (for a table datasheet), Query (for a query datasheet), Form (for a form or form datasheet), Report, or Module in the Object Type box in the Action Arguments section of the Macro window. You can't send a macro. If you want to include the active object, select its type with this argument, but leave the Object Name argument blank.

Object Name

The name of the object to include in the mail message. The Object Name box shows all objects in the database of the type selected by the Object Type argument. If you leave both the Object Type and Object Name arguments blank, Microsoft Access sends a message to the mail application without any database object.

If you run a macro containing the SendObject action in a library database, Microsoft Access looks for the object with this name first in the library database, then in the current database.

Output Format

The type of format you want used for the included object. You can click HTML (*.html), Microsoft Excel (*.xls), MS-DOS Text (*.txt), or Rich Text Format (*.rtf) in the Output Format box. Modules can be sent only in MS-DOS text format. If you leave this argument blank, Microsoft Access prompts you for the output format.

Note You can't include objects in Microsoft ActiveX Server (*.asp) or Microsoft IIS (*.htx, *.idc) format, although these selections are displayed in the list.

To

The recipients of the message whose names you want to put on the To line in the mail message. If you leave this argument blank, Microsoft Access prompts you for the recipients' names.

Separate the recipients' names you specify in this argument and in the Cc and Bcc arguments with a semicolon (;) or with the list separator set on the Number tab of the Regional Settings Properties dialog box in Windows Control Panel. If the mail application can't identify the recipients' names, the message isn't sent.

Cc

The recipients of the message whose names you want to put on the Cc ("carbon copy") line in the mail message. If you leave this argument blank, the Cc line in the mail message is blank.

Bcc

The recipients of the message whose names you want to put on the Bcc ("blind carbon copy") line in the mail message. If you leave this argument blank, the Bcc line in the mail message is blank.


(continued)

Action argument

Description

Subject

The subject of the message. This text appears on the Subject line in the mail message. If you leave this argument blank, the Subject line in the mail message is blank.

Message Text

Any text you want to include in the message in addition to the database object. This text appears in the main body of the mail message, after the object. If you leave this argument blank, no additional text is included in the mail message. If you leave the Object Type and Object Name arguments blank, you can use this argument to send a mail message without a database object.

Edit Message

Specifies whether the message can be edited before it's sent. If you select Yes, the electronic mail application starts automatically, and the message can be edited. If you select No, the message is sent without providing a chance to edit the message. The default is No.

Template File

The path and file name of a file you want to use as a template for an .html file. The template file is a file containing HTML tags.


Remarks

The SendObject action is available only if you have a MAPI-compliant electronic mail application installed on your computer, or if you have a VIM-compliant electronic mail application and have installed and set up Mapivim.dll. For information on how to install and set up Microsoft Access support for VIM mail applications, see Microsoft Office 97 Resource Kit.

The object in the mail message is in the selected output format. When you double-click the object, the appropriate application starts with the object opened. The application for each type of output format is Microsoft Excel (for .xls files), Microsoft Windows Notepad (for .txt files), and Microsoft Word (for .rtf files). For .html files, your default Internet browser (such as Microsoft Internet Explorer) starts.

The following rules apply when you use the SendObject action to include a database object in a mail message:

  • You can send table, query, and form datasheets. In the included object, all fields in the datasheet look as they do in Microsoft Access, except fields containing OLE objects. The columns for these fields are included in the object, but the fields are blank.
  • For a control bound to a Yes/No field (a toggle button, option button, or check box), the output file displays the value –1 (Yes) or 0 (No).
  • For a text box bound to a Hyperlink field, the output file displays the hyperlink for all output formats except MS-DOS text (in this case, the hyperlink is just displayed as normal text).
  • If you send a form in Form view, the included object always contains the form's Datasheet view.
  • If you send a report, the only controls that are included in the object are text boxes (for .xls files), or text boxes and labels (for .rtf, .txt, and .html files). All other controls are ignored. Header and footer information is also not included. The only exception to this is that when you send a report in Microsoft Excel format, a text box in a group footer containing an expression with the Sum function is included in the object. No other control in a header or footer (and no aggregate function other than Sum) is included in the object.
  • Subreports are included in the object, but subforms aren't.
  • When you send a datasheet or form in HTML format, one .html file is created. When you send a report in HTML format, one .html file is created for each page in the report.
Tip If you send the data in a report and the columns and rows of data in the included object don't align as in the report, the following tips may help:

  • You can point to Size on the Format menu, then click To Fit to size the controls.
  • You should avoid overlapping controls or placing controls too close together.
  • You can point to Align on the Format menu, then click the appropriate command to align the controls on the report. Controls that aren't aligned in the same row may be placed in separate rows in the included object, causing additional spacing.
The SendObject action has the same effect as clicking Send on the File menu, and the action arguments correspond to the settings in the Send dialog boxes. The Send command, however, applies only to the active object. If you use the SendObject action, you can specify the object you want to send.

Note You can send the selected data with the Send command. However, this functionality isn't available with the SendObject action.

To run the SendObject action in Visual Basic, use the SendObject method of the DoCmd object.

See Also

OutputTo action, SendObject method.