O$ - Outlook Automation

Alan Perrin alanperrin at assistechea.co.uk
Tue Apr 14 11:40:17 EDT 2009

Hello All
I am a complete novice with Automation and am seriously struggling to make
progress when I attempt to create and send an email via automation.  I have
searched the list archives for help and have created what seems to be the
most successful methods below, but can get no further than the following
error message which appears in $OutlookSendMail method line 7 : -
Error E125207 : Problem with notation
$root.$iwindows.Testemail.iOutlookObj.$activeExplorer  When evaluating
$activeExplorer  Unrecognised custom attribute.
I am using Win XP Pro SP3 and O$ version non-unicode.  My Outlook
2003 application appears as "Outlook.Application.11" in the
GetAutomationObject method - which seems OK to me.
I can see from the list archive that Outlook automation has caused various
problems in the past and I thought I had benefitted from the solutions
given!  But no, I must be missing something important.
Can anyone please help to spot where I have gone wrong? :-
##### Method '$OutlookSendMail' #####
No. Parameter Type Subtype Init.Val/Calc Description
1 pEmailName Character 100000000 'Jake The Peg' 
2 pEmailAddress Character 100000000 'jakethepeg at anydomain.co.uk'
<mailto:'jakethepeg at anydomain.co.uk'>  
3 pSubject Character 100000000 'Testing Email Automation' 
4 pBody Character 100000000 'Hello there sunshine!' 
5 pAttachment Character 100000000 con(PDF_PATH,'AQ1Stock Inventory.pdf')
6 pDisplayName Character 100000000 'My Attachment' 
7 pEmailAction Short integer (0 to 255) 2

No. Local Variable Type Subtype Init.Val/Calc Description
1 Name Character 100000000 
2 Success Boolean
No. Method text
2 Do method GetAutomationObject ("Outlook.App") Returns iOutlookObj
4 Calculate Name as con(pEmailName,'<',pEmailAddress,'>')
5 Do iOutlookObj.$createobject()     ;; start Outlook
7 Do iOutlookObj.$activeExplorer()
8 Do iOutlookObj.$createItem(0) Returns iMailItem     ;; Create a new empty
10 Do iMailItem.$subject.$assign(pSubject)     ;; set the subject
11 Do iMailItem.$body.$assign(pBody)     ;; set the body
13 If len(Name)>2
14 Do iMailItem.$to.$assign(Name)     ;; set the recipient
15 End If
17 If len(pAttachment)>0
18 Do iMailItem.$attachments Returns iAttachment
19 Do iAttachment.$xadd(pAttachment,1,1,pDisplayName)
20 End If
22 Do iMailItem.$save()
23 Do iOutlookObj.$visible.$assign(1)
25 If pEmailAction=0
26 Do iMailItem.$display(kFalse) Returns Success     ;; Display the mail
item in modal form
27 Else If pEmailAction=1
28 Do iMailItem.$send     ;; Send the message
29 Else If pEmailAction=2
30 Do iMailItem.$save     ;; Place a copy in the drafts folder
31 End If

##### Method 'GetAutomationObject' #####
No. Parameter Type Subtype Init.Val/Calc Description
1 pString Character 100000000

No. Local Variable Type Subtype Init.Val/Calc Description
1 lExternalsList List  
2 lTempRow Row
No. Method text
1 Do lExternalsList.$cols.$add('ExternalName',kCharacter,kSimplechar,100)
;; Create a list with a column for names of automation objects
;; Build a list of all Automation objects
3 Do lExternalsList.$sort($ref.ExternalName,kTrue)     ;; Put the most
current version of the Object at the top of the list.
4 Do lTempRow.$cols.$add('Object',kObject,con(".Automation
Library.Automation\",lExternalsList.1.ExternalName))     ;; Create an
instance of the
automation object inside a row variable
5 Quit method lTempRow.Object     ;; Return the object to the calling

Alan Perrin
Assistech (East Anglia) Ltd

More information about the omnisdev-en mailing list