More Edura Scripting Knowledge Please

While I have a script which instructs EUDORA to create an email and send, I’m having problems creating the syntax to attatch a document to the message being sent. Can anyone help a beginner with the exact syntax please. :smiley: [/b]

After you create a new message you should be able to refer to it as
“message 0”

I think this line should work.

set attachment of message 0 to "Mac HD:Some Folder:Some File

Best,

Maybe this will work with a bit of tweaking.

tell application "Eudora"
	
	attach to message 1 of mailbox "Out" documents ¬
		{alias "Mac HD:Desktop:test1.sit", ¬
			alias "Mac HD:Desktop:test2.sit"}

end tell

tried

attach to message 1 of mailbox “Out” documents ¬
{alias “Mac HD:Desktop:test1.sit”, ¬
alias “Mac HD:Desktop:test2.sit”}

got Execution Error
Eudora got an error:message 1 of mailbox “Out” doesn’t understand the attach to message

tried

set attachment of message 0 to "Mac HD:Some Folder:Some File

got

Execution Error
Eudora got an error:Can’t set attachment of message 0 to “MY Mac HD:My Folder:the File I want to attatch”

Can anyone work out where I am going wrong?

Many Thanks

I tested the code above before I posted it and it worked ok. Did you have a unsent message in the outbox when you tried the script? Did you change the files in the script to a file or files that exist on your machine? Which version of Eudora are you scripting?

Not your fault. Eudora 5.2 is mostly a fine email client, but its scripting implementation is bizarre, broken and a pain to use.

on makeMessage(toText, subjectText, bodyText, attachmentsList)
	tell application "Eudora"
		set msgRef to make new message at end of mailbox "Out"
		set msgRef's field "To" to toText
		set msgRef's field "Subject" to subjectText
		set msgRef's body to bodyText
		attach to msgRef documents attachmentsList
		queue msgRef
	end tell
	return msgRef -- (in case you want to refer to this message later)
end makeMessage

on transferMail()
	tell application "Eudora" to connect
end transferMail

-------
--TEST

set toText to "fred@nowhere.dom"
set subjectText to "Hi Fred!"
set bodyText to "Thought you'd like to see this!"
set attachmentsList to {alias "Macintosh HD:Users:FOO:Documents:BAR.rtf"}
makeMessage(toText, subjectText, bodyText, attachmentsList)
-- transferMail()

Hello Has,

Your solution worked perfectly, creating the email with attatchment.

Like very much how you took the time to carefully explain and provide a test.

Thank you

My only problem now is that while the attatchment was in the process of being sent I got:

Execution Error
Eudora got an error:AppleEvent timed out.

Can you help please.

all the best :smiley:

When you ran the script, was your computer already connected to the Internet, or did it have to dial up or do something else to establish a connection?

The AppleScript automatically (at a specified time) connects to the internet at it’s start, allowing Internet Explorer to retrieve information.

It stays on the net while the information is processed by FileMakerPro with TexEditPlus.

Eurdora then takes this information, makes emails and sends them.

Only one of these has an attatchment.

If I run the process without the attatchment included, it runs fine.

The attatchment is about 300K.

It appears to my intrained eye that the time it needs to send the attatchment causes the problem.

There is a shutdown sequence which follows the sending of the emails, closing open applications and disconnecting remote access.

It is vital to me that this process be totally automated, as it takes place on a remote unmanned machine. If I click away the Execution Error box, the emails do continue to send, but in practice I won’t actually be there to do this.

Thank you very much for your help.

It looks like Eudora doesn’t provide a result after it sends a message. This causes the rest of the script to execute before it should. Eudora’s dictionary includes ‘start notifying’ and ‘stop notifying’ commands. I’ve never used them, so I don’t know how they behave, but they might be what your script needs to run successfully.

Try wrapping your script with the following to avoid the timeout error:

with timeout of 14400 seconds
{script}
end timeout

You can adjust the seconds to whatever. 14400 is just a good large number used in the script I learned it in and has no specific meaning.

Also, I’ve never had good luck with setting a variable to a new message in Eudora and find myself having to constantly refer to it as “message 0” - I am using v5.1

Best,

Wraping the part of the script that does the sending with

with timeout of 14400 seconds
{script}
end timeout

did the trick

many many thanks to all

:smiley: :smiley: :smiley: :smiley:

I’ve found that it’s best to use the unique message ID. This avoids problems where the selected message might be changed by a user while the script is running.

tell application "Eudora"
	set messID to id of (make new message at end of mailbox "Out")
	-- do stuff to: message messID
end tell

I considered myself well versed in the Eudora dictionary but didn’t know about that.
Thanks a bunch for that tip Rob. Now to go back and retrofit :shock:

I have used the script code bits in this thread to great effect (you guys are awesome!) but am having problems figuring out how to specify which personality the message being sent originates from.
I can set the From field with no problem and it shows correctly in the delivered message, but the message is still actually sent from the <> personality’s mailserver.

I hope this makes sense - if not email or post here for clarification.

Thanks in advance :smiley:

Andy

One of my personalities is named “rob@macscripter.net” (this is what shows up in Eudora’s personality menu in each message). To set the personality of the front message, I would use:

tell application "Eudora" to set personality of message 0 to personality "rob@macscripter.net"

Thanks, Rob. Worked like a charm. I was on the right track, but couldn’t get the syntax right.

Are there any good references for a total newbie such as myself?

I am familiar with a few other programming environments/languages/syntax but this is my first try at applescripting.

Thanks again for the help

Andy

To get a good overview of AppleScript in general, it would probably be helpful to study the AppleScript Language Guide. It’s also available in PDF. While this is somewhat out of date, much of the material is still relevant.

To learn about a particlar application, it’s very helpful to download and inspect scripts that others have written. Many of the scripts at ScriptBuilders can be inspected and modified. There are also books which are very helpful. Our own T.J. Mahaffey has reviewed and recommended one such book in his unScripted article titled Book review: AppleScript for Applications, 2001 Edition.

And then there’s this BBS. If you get stuck, there’s usually someone who has encountered a similar problem and has one or more solutions to offer. :slight_smile: