O$ - Outlook Automation
Fred Brinkman
fred.brinkman at euromnis.org
Tue Apr 14 11:56:25 EDT 2009
Alan,
what I use;
(should you not get this to work, contact me off-list, I'll send you a
piece of code)
Method "GetAutomationObject"
Do lExternalsList.$cols.$add('ExternalName',kCharacter,kSimplechar,
100) ;; Create a list with a column for names of automation objects
Do $root.$extobjects.Automation Library.$objects.
$sendall(lExternalsList.$add($ref.$name),upp(mid($ref.$name,
1,len(pString)))=upp(pString)) ;; Build a list of all Automation
objects who
Do lExternalsList.$sort($ref.ExternalName,kTrue) ;; Put the most
current version of the Object at the top of the list.
Do lTempRow.$cols.$add('Object',kObject,con(".Automation
Library.Automation\",lExternalsList.1.ExternalName)) ;; Create an
instance of the automation object inside a row variable
Quit method lTempRow.Object ;; Return the object to the calling
method.
You now have to make sure of course you have your object!!
(lTempRow.Object)
Then to send your mail
Method "Send ViaOutLook"
Do method GetAutomationObject ("Outlook.App") Returns iOutlookObj
Calculate lvNaam as con(pEmailNaam,'<',pEmailAddress,'>')
Do iOutlookObj.$createobject() ;; start outlook #F
Do iOutlookObj.$activeExplorer()
Do iOutlookObj.$createObject()
Do iOutlookObj.$createItem(0) Returns iMailItem ;; Create a new
empty mail
Do iMailItem.$subject.$assign(pSubject) ;; set the subject
Do iMailItem.$body.$assign(pBody) ;; set the body
If len(lvNaam)>2
Do iMailItem.$to.$assign(lvNaam) ;; set the recipient
End If
If len(pAttachment)>0
Do iMailItem.$attachments Returns iAttachment
Do iAttachment.$xadd(pAttachment,1,1,pDisplayName)
End If
Do iMailItem.$save() ;; fb181206
Do iOutlookObj.$visible.$assign(1)
If pEmailAction=0
Do iMailItem.$display(kFalse) Returns succes ;; Display the mail
item in modal form
Else If pEmailAction=1
Do iMailItem.$send ;; Send the message
Else If pEmailAction=2
Do iMailItem.$save ;; Place a copy in the drafts folder
End If
Do iMailItem.$release ;; iMailItem
Do iOutlookObj.$release
iAttachment, iMailItem and iOutlookObj are variables of type Object
lvNaam is a variable of type Character, succes a variable of type
Number long integer
all the pVariables are parameters with adres, subject, body and so on.
Hth,
Fred
Fred Brinkman
http://www.euromnis.org
**********************************************
Fred Brinkman Consultancy
B-1000 Brussels
Tel. +32-474-83 80 80
Fax +32-2-330 10 31 (on request)
mailto:fred.brinkman at euromnis.org
*********************************************
Op 14 apr 2009, om 17:40 heeft Alan Perrin het volgende geschreven:
> 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 4.2.0.8 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
> 1
> 2 Do method GetAutomationObject ("Outlook.App") Returns iOutlookObj
> 3
> 4 Calculate Name as con(pEmailName,'<',pEmailAddress,'>')
> 5 Do iOutlookObj.$createobject() ;; start Outlook
> 6
> 7 Do iOutlookObj.$activeExplorer()
> 8 Do iOutlookObj.$createItem(0) Returns iMailItem ;; Create a
> new empty
> mail
> 9
> 10 Do iMailItem.$subject.$assign(pSubject) ;; set the subject
> 11 Do iMailItem.$body.$assign(pBody) ;; set the body
> 12
> 13 If len(Name)>2
> 14 Do iMailItem.$to.$assign(Name) ;; set the recipient
> 15 End If
> 16
> 17 If len(pAttachment)>0
> 18 Do iMailItem.$attachments Returns iAttachment
> 19 Do iAttachment.$xadd(pAttachment,1,1,pDisplayName)
> 20 End If
> 21
> 22 Do iMailItem.$save()
> 23 Do iOutlookObj.$visible.$assign(1)
> 24
> 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
> 2
> ;; 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
> method.
>
>
>
> Alan Perrin
> Assistech (East Anglia) Ltd
>
>
>
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
More information about the omnisdev-en
mailing list