Date post: | 25-Dec-2015 |
Category: |
Documents |
Upload: | willa-stevens |
View: | 214 times |
Download: | 0 times |
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Putting Outlook®
in OpenEdge®
Paul Guggenheim
Paul Guggenheim & Associates
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
2About PGA
Working in Progress since 1984 and training Progress programmers since 1986
Designed seven comprehensive Progress courses covering all levels of expertise including - The Keys to OpenEdge®
Author of the Sharp Menu System, a database driven, GUI pull-down menu system.
White Star Software Strategic Partner
TailorPro Consultant and Reseller
AppPro Partner
Major consulting clients include Acument Global Technologies, Chicago Metal Rolled Products, Eastern Municipal Water District, Eaton Corporation, Foxwoods Casino, Interlocal Pension Fund, International Financial Data Services, JP Morgan Chase, Montana Metal Products, National Safety Council and Tyson Foods.
Head of the Chicago Area Progress Users Group
PUG Challenge Executive Committee Member
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Overview
Object Linking and Embedding (OLE) OLE Servers OLE Clients Using OLE in OpenEdge
Create an Instance Refer to related objects using properties and
methods Release Objects from Memory
GUI for .NET Defining temp-tables and ProDataSets Using the ProBindingSource Linking Ultragrid and other UI Objects
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Overview (cont.)
Applying OLE and GUI for .NET in an Email Application Representing Email History Exhibiting Email Messages Showing Outlook Folders Populating the UltraCombo Mailbox Object Populating the UltraGrid Mail Item
Object Updating the email table from UltraGrid
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
What is OLE?
OLE Automation, or Object Linking and Embedding, is an effective way for a Progress application to communicate with other applications in the MS Windows environment.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Before OLE
The legacy method of communicating with a word processor or spreadsheet is to dump data to an ASCII file and then load the ASCII file into the other application.
This process involved several manual steps, making it difficult to automate and secure against end user errors.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
OLE Automation
OLE Automation is a client/server based form of communication.
An OLE Automation Server is an application that can be controlled by other applications.
An OLE Automation Client is an application that can issue server commands.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
OLE Automation
Examples of OLE Automation Servers are: Microsoft Word Microsoft Excel Microsoft Outlook Microsoft Powerpoint Microsoft Mappoint
An OpenEdge GUI client is an OLE Automation Client.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
OLE Information
To learn about how to use OLE Automation, check the following: Progress COM Object Viewer Record Macros in the OLE Automation
Server and look at the Visual Basic Application (VBA) source code produced.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
OLE Information
To learn about how to use OLE Automation, check the following: Visual Basic for Applications Help
Use the Object Browser to determine the value of constants
Internet MS Office Developer Website
(http://www.msdn.microsoft.com/office) MS Office Development Documentation (
http://msdn.microsoft.com/en-us/library/office)
MS Outlook Reference Documentation(http://msdn.microsoft.com/en-us/library/office/
aa246142%28v=office.11%29.aspx)
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
OLE Automation Servers
The OLE Automation Server application consists of components called objects or collections. They relate to each other hierarchically.
Each object consists of properties and methods that are analogous to Progress widget attributes and methods.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Using OLE in Progress – 3
Steps
1. Create an instance
2. Refer to other objects using properties and methods
3. Release Objects from memory
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Using OLE in Progress
1. Create an instance Examples:
def var hwordapp as com-handle.create "word.application" hwordapp.def var ool as com-handle.create "Outlook.Application" ool.
In order for an instance to be created, the server application must be registered to the same machine as the running OpenEdge client, and the server program files must be located either on the same machine or a shared network drive.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Using OLE in Progress
CREATE statementCREATE expression1 COM-hdl-var
[CONNECT [TO expression2]][NO-ERROR]
expression1 is a reserved character string that names a unique Automation object in the system registry.
expression2 is a character string that identifies a file name of a particular application type, like .doc for Word files or .xls for Excel files.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Using OLE in Progress
2. Refer to other objects using properties and methods Example:
def var hdoc as com-handle.hdoc =
hwordapp:documents:open("worddoc.doc"). Documents is a collection object belonging
to the Word applicaton, using the method Open. This method opens an existing Word
document called "worddoc" and stores the reference to it in a variable called hdoc.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Using OLE in Progress
Example:def var ons as com-handle.def var opf as com-handle.def var opfs as com-handle.ons = ool:GetNameSpace("MAPI").opf = ons:folders:item(1).opfs = opf:folders.
Folders is a collection object belonging to the Outlook applicaton. A collection allows the access to multiple
items through the count property and item method.
The first item in the above example represents “Personal Folders”. We want to read the folders below Personal Folders.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Working with Collections
The following illustrates the similarities of collections I have studied in Microsoft Automation Servers:1. The collection name is plural, i.e
Adjustments, Windows, Bookmarks, Folders, etc.
2. Each individual object inside of a collection usually is singular, i.e. Window, Bookmark, Folder, etc. (Adjustment doesn't exist).
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Working with Collections
The following illustrates the similarities of collections I have studied in Microsoft Automation Servers:3. There is a read-only Count property that
returns an integer representing the number of items in a collection.
4. There is an Item method that expects an integer representing the unique sequence number for a particular item in a collection.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Working with Collections
To read through the folders collection:
do i = 1 to opfs:count with down:
display opfs:item(i):name.
end.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Using OLE in Progress
3. Release objects from memory Example:
release object hdoc no-error.release object hwordapp no-error.release object ool no-error.release object ons no-error.release object opf no-error.release object opfs no-error.
Limits - Usually hundreds of server objects may be controlled by a client.
OpenEdge has automatic garbage collection for versions 10.2B and later.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Using OLE in Progress
RELEASE statementRELEASE OBJECT COM-hdl-var
[NO-ERROR] Once a COM object is released, any
references to it could result in an invalid handle error. Warning: Since a new COM object could be
given the same handle as one that was deleted, you should always set COM-hdl-var to ‘?’ after releasing the object and use the VALID-HANDLE function to see if it refers to anything before referencing it or use the NO-ERROR keyword.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
GUI for .NET
In the OpenEdge traditional GUI, a browse is connected to data via a query that is related to a database table, a temp-table or a prodataset.
In the OpenEdge GUI for .NET, the equivalent to a browse is called a grid. A grid connects to data using a binding source. OpenEdge offers the ProBindingSource to establish a connection.
In the following examples, the Infragistics UltraGrid objects will be used for grids.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
OpenEdge ProBindingSource
The ProBindingSource is an OpenEdge object that transfers data to and from .NET UI objects.
It typically maps fields from a temp-table using a query or a ProDataSet to the fields defined in the ProBindingSource
.NET UI ProBindingSource Query or PDS
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
ProBindingSource Steps
Below are the required steps for the ProBindingSource to communicate with an UltraGrid or other .NET objects.
Attach ProBindingSource to .NET object’s DataSource property.
Define a temp-table that contains the fields that will be used in the UltraGrid columns or .NET object.
Define a scrolling query based on that temp-table.
Populate the temp-table.
Open the query for the temp-table.
Attach the query to the ProBindingSource.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Attach to Combo Box DataSource
Property
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Populating UltraCombo
Mailbox Define Temp-table tmailbox
define temp-table tmailbox no-undo
field mbname as char format "x(30)" label "Mailbox"
index mbname is unique mbname.
Define Scrolling Query
define query qtmailbox for tmailbox scrolling.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Populating UltraCombo
Mailbox Populate the Temp-Table /* Get handle for Personal Folders */
opf = ons:folders:item(1).
/* Get handle for Personal Folders Collection */
opfs = opf:folders.
do i = 1 to opfs:count:
if opfs:item(i):name = "openedge" then
do:
ooefolder = opfs:item(i).
do j = 1 to ooefolder:folders:count:
create tmailbox.
assign tmailbox.mbname = ooefolder:folders:item(j):name.
end. /* j = 1 to ooefolder:count */
end. /* = "openedge" */
end. /* i = 1 to opfs:count */
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Populating UltraCombo
Mailbox Open the query for the temp-table.
open query qtmailbox for each tmailbox.
Attach the query to the ProBindingSource.
bsmailbox:handle = query qtmailbox:handle no-error.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Populating the Mail Items
UltraGrid Attach to the UltraGrid2 DataSource Property
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Populating UltraGrid2 Mail
Items Define temp-table toutemail and query
qtoutemail define temp-table toutemail no-undo
field maildt as datetime-tz
field maildate as date
field mailtime as char format "x(10)"
field sender as char format "x(30)"
field senderemail as char format "x(50)"
field recipient as char format "x(30)"
field recipientemail as char format "x(50)"
field body as char format "x(50)"
index maildt maildt desc.
define query qtoutemail for toutemail scrolling.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Populating UltraGrid2 Mail
ItemsMETHOD PUBLIC VOID outemailfill(input omf2 as com-handle):
empty temp-table toutemail.
bsoutemail:handle = ?.
do i = omf2:items:count to 1 by -1:
omailitem = omf2:items(i) no-error.
create toutemail.
assign toutemail.maildt = datetime(omailitem:creationtime)
toutemail.maildate = date(maildt)
toutemail.mailtime = string(integer(mtime(toutemail.maildt) /
1000),"HH:MM:SSam")
toutemail.sender = trim(omailitem:sendername,"'")
toutemail.senderemail = omailitem:senderemailaddress
toutemail.recipient = trim(omailitem:recipients:item(1):name,"'")
toutemail.recipientemail = omailitem:recipients:item(1):address
toutemail.body = substr(omailitem:body,1,16384).
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Populating UltraGrid2 Mail
Items Reading mail items backwards adds the
most recent ones to the temp-table first.
Convert receivedtime property to maildt datetime-tz field.
Assign sender name, email address, recipient name, email address to the corresponding temp-table fields.
Only store the first 16k of email text characters into the body temp-table field.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Populating UltraGrid2 Mail
Items Open the query for the temp-table.
open query qtoutemail for each toutemail.
Attach the query to the ProBindingSource.
bsoutemail:handle = query qtoutemail:handle no-error.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Filling the Email Database Items
UltraGrid Attach to the UltraGrid1 DataSource
Property
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Filling the Email Database Items
UltraGrid Define temp-table temail and prodataset dsemail. define temp-table temail before-table b4temail
FIELD emailNo AS INTEGER FORMAT "999999" LABEL "Email No."
FIELD studentId AS INTEGER FORMAT "999999"
FIELD emaildtz AS DATETIME-TZ
FORMAT "99/99/9999 HH:MM:SS.SSS+HH:MM"
INITIAL "now" LABEL "Date-Time-TZ"
field emaildate as date
field emailtime as char format "x(10)"
FIELD Contact AS CHARACTER FORMAT "X(20)"
FIELD ContactEmail AS CHARACTER FORMAT "x(40)"
FIELD EmailTxt AS CHARACTER FORMAT "x(40)" LABEL "Text"
field Name as char format "x(30)"
index emailno is unique emailno.
define dataset dsemail for temail.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Filling the Email Database Items
UltraGrid Define query for database table email,
temp-table for temail and data-source for filling.
define query qemail for email.
define query qtemail for temail scrolling.
define data-source srcemail
for query qemail
email keys (emailno).
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Filling the Email Database Items
UltraGrid Prepare Query, Attach Data Source and fill
dataset. query qemail:query-prepare("for each email no-lock").
temp-table temail:tracking-changes = no.
dataset dsemail:EMPTY-DATASET ().
buffer temail:attach-data-source(data-source
srcemail:handle,"").
dataset dsemail:fill().
buffer temail:detach-data-source().
temp-table temail:tracking-changes = yes.
open query qtemail for each temail.
bsemail:handle = query qtemail:handle no-error.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Updating the email table from
UltraGrid Updating the email database table from
Outlook is as easy as double-clicking.
Challenge is to prevent duplicates or adding the same Outlook message more than once. Outlook Mail Item CreationTime property records
milliseconds which virtually insures uniqueness for a specific studentid and contact email address.
When a mail item is selected for adding, the sender and recipient email addresses are checked against the student table. If one matches, the other email address becomes the contact email address.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Demonstration
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Demonstration
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Demonstration – Word Index
Search
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Demonstration – Word Index
Search
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Summary
Applying OLE concepts in an OpenEdge GUI for .NET application provides a seamless way to provide Microsoft Office data in an attractive format.
Integrating the two technologies allows the ability to examine the Office data in meaningful ways using powerful OpenEdge database features such as word indexing.
PUG ChallengeJune 9-12th, 2013
Westford, MA
Copyright © 2013Copyright © 2013 Paul Guggenheim & AssociatesPaul Guggenheim & Associates
Putting Outlook in OpenEdgePutting Outlook in OpenEdge
Questions