1) With the Customer Maintenance window open, press CTRL+F10 to open Modifier.
2) Move the INet1 and INet2 fields to the window area on the Customer Maintenance window. Do not be concerned about the placement of the field since later on they will be moved back to their original positions.
|RM_Customer_Maintenance window as seen in Modifier|
NOTE: This customization re-uses the INet1 and INet2 fields available to support Small Business Manager functionality.
3) Save the changes and return to GP (File > Microsoft Dynamics GP).
4) Grant security to the modified window:
· In v10: Microsoft Dynamics GP > Tools > Setup > System > Alternate/Modified Forms and Reports.
· In v9: Use Advanced Security or the Security options to grant security to the modified window.
5) Open the Customer Maintenance window and add the form to Visual Basic. Press CTRL+F11 on your keyboard.
6) Add fields to Visual Basic. Press Shift+F11 to activate the visual cue. Click on the following fields: INet1, INet2, Customer Number, Write Letters button
7) Open the Visual Basic editor, locate the Microsoft Dynamics GP Objects in the Project Explorer pane, and double-click on the CustomerMaintenance (Window) object.
8) Download and paste the following code in the Code Editor.
WARNING: This customization uses a method of executing Dexterity sanScript code from VBA which is unsupported by Microsoft.
9) From the menu bar, choose Tools | References. Mark the following references: Dynamics Continuum Integration Library, Microsoft Outlook 1x.0 Object Library
Click Ok to continue.
10) From the Debug menu, choose Compile Microsoft_Dynamics_GP.
11) Save the project and close the Visual Basic Editor.
12) From the Customer Maintenance window’s Tools menu, select Customize, then choose Modify Current Window, or press CTRL+F10 on your keyboard.
13) Move the INet1 and INet2 fields back to their original position.
14) Save changes and return to GP.
15) Open the Customer Maintenance window and click on the Write Letters button drop-down list. You will now see the new "Send an Email" option. You will need to select a customer first to continue.
By default, the customization will open the directory specified for Letters in the DEX.INI file.
1. Working with Microsoft Outlook via COM Automation. There are six main steps to sending a Microsoft Outlook mail message by using Automation, as follows:
a) Initialize the Outlook session
b) Create a new message
c) Add the recipients (To, CC, and BCC) and resolve their names
d) Set valid properties, such as the Subject, Body, and Importance
e) Add attachments (if any)
f) Display/Send the message.
Outlook Automation has remained virtually unchanged since Outlook 2000, but you can refer to Microsoft KB article 220595 for more information on the subject.
2. Pass-thru sanScript implemented with Dynamics Continuum Integration Library, to add an item to the letter writing Button Drop-Down List control (for more information on how to dynamically populate a list control read David Musgrave's article on the subject).
Pass-thru sanScript is also used to call the RW_GetInternetInfo function to retrieve customer email address and to read the Letters Path key from DEX.INI file which will in turn serve as a default directory for the attachment dialog.
3. Use of the Common Dialog Box API to return the path to the email attachment. Please refer to my previous article on Using the Win32 Common Dialog Box API to return a file path to a Dynamics GP modified form field as it explains in great detail the use of this API.
You can always download the package files and import using the Customization Maintenance window under Microsoft Dynamics GP > Tools > Customize > Customization Maintenance. Don't forget to include your references as indicated in step 9 above.
Dynamics GP 9.0 package file - Click here
Dynamics GP 10.0 package file - Click here
Once again, I have demonstrated the power of Visual Basic for Applications in Microsoft Dynamics GP and how you can achieve high degrees of integration with the inner works of the system itself and with other desktop applications like Outlook, and even the Windows operating system elements. As usual, please drop me a note if you have any comments on this article or if you would like to see a particular topic discussed on this site.
When choosing references to the Microsoft Outlook Object Library, consider the active version of Outlook you are currently using. The following is a summary of Object Library versions related to their corresponding version of Microsoft Outlook.
Microsoft Outlook 2007 --- Microsoft Outlook 12.0 Object Library
Microsoft Outlook 2003 --- Microsoft Outlook 11.0 Object Library
Microsoft Outlook XP --- Microsoft Outlook 10.0 Object Library
Until next post!
Mariano Gomez, MVP