DoCmd Object.
The SendObject method carries out the SendObject action in Visual Basic. For more information on how the action and its arguments work, see the action topic.
DoCmd.SendObject [objecttype] [, objectname] [, outputformat] [, to] [, cc] [,bcc] [, subject] [, messagetext] [, editmessage]
The SendObject method uses the following arguments.
Argument |
Description |
objecttype |
One of the following intrinsic constants: acQuery |
objectname |
A string expression that is the valid name of an object of the type selected with the objecttype argument. If you want to include the active object in the mail message, specify the object’s type with the objecttype argument and leave this argument blank. If you leave both the objecttype and objectname arguments blank, Microsoft Access sends a message to the electronic mail application without a database object. If you execute Visual Basic code containing the SendObject method in a library database, Microsoft Access looks for the object with this name first in the library database, then in the current database. |
outputformat |
One of the following intrinsic constants: acFormatXLS If you leave this argument blank, Microsoft Access prompts you for the output format. |
to |
A string expression that lists the recipients whose names you want to put on the To line in the mail message. Separate the recipient names you specify in this argument and in the cc and bcc arguments with a semicolon (;) or with the list separator set in the Number tab of the Regional Settings properties sheet in the Windows Control Panel. If Microsoft Access can’t identify the recipient names, it doesn’t send the message. If you leave this argument blank, Microsoft Access prompts you for the recipients. |
cc |
A string expression that lists the recipients whose names you want to put on the Cc line in the mail message. If you leave this argument blank, the Cc line in the mail message is blank. |
bcc |
A string expression that lists the recipients whose names you want to put on the Bcc line in the mail message. If you leave this argument blank, the Bcc line in the mail message is blank. |
subject |
A string expression containing the text you want to put on the Subject line in the mail message. If you leave this argument blank, the Subject line in the mail message is blank. |
messagetext |
A string expression containing the text you want to include in the body of the mail message, after the object. If you leave this argument blank, the object is all that is included in the body of the mail message. |
editmessage |
Use True (-1) to open the electronic mail application immediately with the message loaded, so the message can be edited. Use False (0) to send the message without editing it. If you leave this argument blank, the default (True) is assumed. |
Modules can be sent only in MS-DOS Text format, so if you specify acModule for the objecttype argument, you must specify acFormatTXT for the outputformat argument.
You can leave an optional argument blank in the middle of the syntax, but you must include the argument’s comma. If you leave a trailing argument blank, don’t use a comma following the last argument you specify.
DoCmd Object, OutputTo Method.
This example includes the Employees table in a mail message in Microsoft Excel format and specifies To, Cc, and Subject lines in the mail message. The mail message is sent immediately, without editing.
DoCmd.SendObject acTable, "Employees", acFormatXLS, _ "Nancy Davolio; Andrew Fuller", "Joan Weber", , _ "Current Spreadsheet of Employees", , False