Tip>Designer>Word Functions

Dynamically e-mailing a document

 

Article #:

0006

Contributor:

Gail Moodie

GF version:

3.05

Applies to:

E-mailing from Microsoft Word

Last updated:

July 19, 2001

Description

E-mails the active document as an attachment.

Explanation

Click here to view an explanation.

To e-mail an active document from within the document, insert the following function in a FillPoint at the end of the template:

WordApp.ActiveDocument.SendMail()

The SendMail function will e-mail the document in the state it is in at the time the function is called. It is advisable, therefore, to insert this function at the end of the template in order to send the completed document, i.e. after all FillPoints have been filled.

Your default e-mail client opens in a new message with the document attached. Fill in the details and send the document as follows:

  1. Fill in the addressee details.

  2. By default the Subject line will contain the title that Word has automatically assigned to the document e.g. Document2. But if you have already saved the document, the Subject line will contain a portion of the first line of text in the document.

You can set the contents of the subject line of the e-mail either in the template (each document's e-mail will then have the same subject line) or in the document itself. On the File menu, click Properties. In the Summary tab, type a new title in the Title box. Click OK.

  1. Fill in the body of the message if required.

  2. Click Send to send the message and return to the document.

 

NOTE

  • You may want to save the document before e-mailing it so that the attachment is automatically assigned a more meaningful name. Insert the SaveAs function in a FillPoint before the SendMail function:

%[WordApp.ActiveDocument.SaveAs('Transfer'&Transfer.Name)]

  • It is advisable to insert the SendMail function at the end of the template for the following reasons:

  1. The document will be e-mailed in the state that it is in at the time the function is called, i.e. even if all the FillPoints have not been filled, in which case the document will be incomplete.

  2. The e-mail dialog behaves asynchronously (non-modally), which means that the filling process will continue while the message is being composed and sent.

 

Template example