Sending email from Omnis 7

I am completely new to Applescript, please forgive any dislayed ignorance.

I am developing an Omnis 7 application that runs in OSX(Classic mode). I need to create a script that will send an email (utilising Mail or Entourage or Outlook or other).

I see the example script provided with OSX 3 in which the user enters the name, text etc.

I want to send this data from my application with no user intervention except, perhaps, click the send button.

Can I send the data to the script by something like:

Launch MyMailScript (NAME,ADDRESS,SUBJECT,TEXT,ATTACHMENTPATH)

or should I start the script and code it so it calls back the the application to get the data?

Any advice, examples, already invented wheels etc welcome.

Mike

Where are you getting the To address and subject and body from? Are they in your Omnis 7 application? If so, and if Omnis 7 is scriptable, you’ll need to take the “send mail” script you have, make its code to send mail into a handler (if it isn’t already), and save it as an application. Then, you can run a script that gets the information from Omnis, then calls the handler in the applet you compiled.

For example:


tell application "SendMail" to sendMail(someToAddress, someSubject, someBodyText)

Of course, you’ll need to set someToAddress, someSubject, and someBodyText first. Is Omnis 7 scriptable? Does it have the ability to run AppleScript within it (ie. a Scripts menu, or somewhere it can run AppleScript directly)?

Let us know more about Omnis 7, and where the email data needs to get pulled from.

Thanks Kroni for your reply.

Omnis has been around since about 1982. Its a database development tool that since Omnis 7 is completely cross-platform Mac, PC, Linux and I believe Sun Solaris. Written in C++ it comprises a run-time which is platform specific and my application file which will work with any platform. I write on Mac and can email to a PC user and it runs. Very cool. Latest version is Omnis Studio, object-oriented etc with all bells and whistles. SQL capable but has its own datafile system also. 1984 version will run on Mac OSX (classic mode). Omnis has a small but very loyal following and is used for many extremely serious projects. Published by Raining Data Corp. (used to be Pick )

Now my little problem. I have an Omnis application running (in Classic), a window open and the user keying in the address, subject, message etc for an email. I want to be able to send this stuff to Mail on the click of a button. I have looked at Apples script CreateNewMessage that comes with Panther. I have made this into an .app

In Omnis my button does:
Enable apple events
Launch OSX:Library:Scripts:Mail Scripts.MyMailScript.app

This sucessfully runs the script application. But, rather than have the user type the stuff in again I want the script to get the data from my window:


tell "Omnis 7" 
set theAddress to Get Data "address"
set the result to display dialog theAddress
end tell

This shows me a dialog window:
“addreess” doesn’t understand the <> message

Obviously I am not doing something I should. How do I find out what it is?

Cheers

Mike

Drop the Omnis application on Script Editor to open its AppleScript dictionary. Then, post it here. Maybe we can help you see how to get information from Omnis. It looks like either the command is not Omnis’s command, or you are using the wrong syntax.

Thanks again Krioni. Here is what I think is the most relevant part of the dictionary. (I do not see how to send the entire file)

Core Suite: Suite that applies to all applications

Class alias: a file on a disk or server. The file must exist when you check the syntax of your script.
Plural form:
aliases
Properties:
POSIX path string [r/o] – the POSIX path of the file

Class application: An application program
Plural form:
applications
Properties:
name international text [r/o] – the name of the application
frontmost boolean [r/o] – Is this the frontmost application?
selection selection-object – the selection visible to the user. Use the ‘select’ command to set a new selection; use ‘contents of selection’ to get or change information in the document.
clipboard a list of anything – the contents of the clipboard for this application
version version [r/o] – the version of the application

Class document: A document of a scriptable application
Plural form:
documents
Properties:
modified boolean [r/o] – Has the document been modified since the last save?

Class file: a file on a disk or server
Plural form:
files
Properties:
POSIX path string [r/o] – the POSIX path of the file

Class insertion point: An insertion location between two objects
Plural form:
insertion points

Class selection-object: A way to refer to the state of the current of the selection. Use the ‘select’ command to make a new selection.
Properties:
contents anything – the information currently selected. Use ‘contents of selection’ to get or change information in a document.

Class window: A window
Plural form:
windows
Properties:
bounds bounding rectangle – the boundary rectangle for the window
closeable boolean [r/o] – Does the window have a close box?
titled boolean [r/o] – Does the window have a title bar?
index integer – the number of the window
floating boolean [r/o] – Does the window float?
modal boolean [r/o] – Is the window modal?
resizable boolean [r/o] – Is the window resizable?
zoomable boolean [r/o] – Is the window zoomable?
zoomed boolean – Is the window zoomed?
visible boolean – Is the window visible?

Get Data: Get data from Omnis field.
Get Data reference – Field name to get data from.
Result: string – Result of get data

Set Data: Set an Omnis field data
Set Data reference – Field to set data in
[The Data anything] – Data for field. Text prefered, but PICT acepted.

class info: (optional) Get information about an object class
class info type class – the object class about which information is requested
[in ‘intl’] – the human language and script system in which to return information
Result: type class info – a record containing the object’s properties and elements

close: Close an object
close reference – the object to close
[saving yes/no/ask] – specifies whether changes should be saved before closing
[saving in file] – the file or alias in which to save the object

count: Return the number of elements of an object
count reference – the object whose elements are to be counted
[each type class] – if specified, restricts counting to objects of this class
Result: integer – the number of elements

data size: (optional) Return the size in bytes of an object
data size reference – the object whose data size is to be returned
[as type class] – the data type for which the size is calculated
Result: integer – the size of the object in bytes

delete: Delete an object from its container. Note this does not work on script variables, only on elements of application classes.
delete reference – the element to delete

duplicate: Duplicate one or more objects
duplicate reference – the object(s) to duplicate
[to location reference] – the new location for the object(s)
[with properties record] – the initial values for properties of the new object that are to be different from the original
Result: reference – to the duplicated object(s)

event info: (optional) Get information about the Apple events in a suite
event info type class – the event class of the Apple events for which to return information
[in ‘intl’] – the human language and script system in which to return information
Result: a list of type event info – a record containing the events and their parameters

exists: Verify if an object exists
exists reference – the object in question
Result: boolean – true if it exists, false if not

make: Make a new element
make
new type class – the class of the new element
[at location reference] – the location at which to insert the element
[with data anything] – the initial data for the element
[with properties record] – the initial values for the properties of the element
Result: reference – to the new object(s)

move: Move object(s) to a new location
move reference – the object(s) to move
to location reference – the new location for the object(s)
Result: reference – to the object(s) after they have been moved

open: Open the specified object(s)
open reference – list of objects to open

print: Print the specified object(s)
print reference – list of objects to print

quit: Quit an application
quit
[saving yes/no/ask] – specifies whether to save currently open documents

reopen: Reactivate a running application. Some applications will open a new untitled window if no window is open.
reopen

run: Run an application. Most applications will open an empty, untitled window.
run

save: Save an object
save reference – the object to save, usually a document or window
[in file] – the file or alias in which to save the object
[as type class] – the file type of the document in which to save the data

select: Make a selection
select reference – the object to select

suite info: (optional) Get information about event suite(s)
suite info type class – the suite for which to return information
[in ‘intl’] – the human language and script system in which to return information
Result: a list of type suite info – a record containing the suites and their versions

Hope you can assist, without wasting too much of your time.

Cheers

Mike

I’m a little suspicious of the wording of the dictionary. It claims that the parameter for the ‘Get Data’ command is a reference, but then says you are just supposed to give it a field name. Notice that the ‘Set Data’ command says reference too, but does not say field name. I wonder if the command should look like this:


Get Data field "address"

rather than just Get Data “address”

Is there a section in the dictionary that describes a field object? Also, I see no reference to which record’s field to get data from. In FileMaker, you have to specify it like this:


get field "address" of current record

Another possibility is a simple typo. I noticed that the error message you gave was the following:

Did it really say “addreess” with two e’s? :slight_smile: