Mail Merge to Microsoft Outlook
UI Builder for Microsoft Access can help you send professional, formatted emails from Microsoft Access in a single click. Download a free trial today.
Microsoft Access is a powerful tool for handling data and creating report forms. With the emergence of the Internet as a major factor in all business application, it has become vital to have connectivity in all spheres.
Suppose you have an Inventory Management application in MS Access. Herein the various products, their inventory levels and the reorder level are stored. On a product reaching reorder level, a Form letter to the supplier is generated. Wouldn't it be more convenient if an email were generated directly from the application?
The SendObject Method of MS Access does just that. Embed it in your report and on click of a button an email will be generated directly from the application. The SendObject action can attach a MS Access form, table, report or query in an electronic mail message. Microsoft Excel 2000 (*.xls), MS-DOS text (*.txt), rich-text (*.rtf), or HTML (*. html) files can also be dispatched through SendObject. All these attachments can be read and forwarded too. For sending, any electronic mail application that uses the Microsoft Mail Applications Programming Interface (MAPI) can be used. To send Microsoft Access objects to the Vendor Independent Mail (VIM) mail applications, the dynamic link library Mapivim.dll, which converts the MAPI messages to VIM protocol, has to be installed and set.
DoCmd.SendObject [type][, name][, format][, to][, cc][, bcc][, subject][, body][, edit][, template_file]
The SendObject method has the following arguments:
|Type||This is the type of the object attached to the mail. The options
If nothing is specified acSendNoObject is taken as default. This is also to be selected when there is no attachment.
|Name||This string expression is a valid name for the object type declared above. If the object is to be incorporated in the mail message, define the type argument and leave the name blank|
|Format||This is the format of the output for the attached object. The
|To||This string expression list those recipients’ email addresses who are to appear on the To line of the mail. A semicolon separates the addresses (;). If the mail application does not recognize these email addresses, the application throws an error and the mail is not sent. If this argument is left blank Microsoft Access prompts you for it.|
|cc||This string expression list those recipients’ email addresses that are to appear on the cc line of the mail. When left blank, the cc line in the mail message is blank.|
|bcc||This string expression lists those recipients’ email addresses that are to appear on the bcc line of the mail. When left blank, the bcc line in the mail message is blank.|
|Subject||This string expression shows the matter to be depicted in the Subject line of the mail.|
|Body||This is the main message text of the mail. If an object is included, this message comes after the object is displayed. When left blank only the attached object is mailed.|
|Edit||This toggle argument denotes whether the email message can be edited before sending. To open the electronic mail application with the message loaded, select True (-1). False (0) is used when the message is not to be edited. The default is True.|
|Templatefile||This string expression has the full path and name of the file containing the template for a HTML file.|
Now we have the complete syntax. Let us see an example:
DoCmd.SendObject acSendTable, "emp_mast", acFormatXLS, , _ "firstname.lastname@example.org", , "Bank payment", , False
This example sends a table EMP_MAST in MS Excel format to email@example.com as cc . The subject line is Bank Payment and the body is blank. This mail is not opened for editing.
In an application, this code can be attached to the onClick event of a Command Button. The arguments like To, cc, bcc can be selected from drop down lists in a form. The object attached, say a letter to a supplier, can be a report with run time variables.
Hopefully this example explains the Send Object action clearly. See the following article for an example of Using the SendObject Method for Sending E-Mails from a Microsoft Access Database