Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7039 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

hello all,

osx has its own inbuild smtp server, not a secret. i have a script with only one step (perform applescript) which contains this

 

do shell script "echo hello | mail -s 'test' [email protected]" 

this sends one email with the content hello and the subject test to [email protected]. now the question is how can i parse the contents of a text field instead of just hello? i must somehow let it know which field, like set the field to somefield, and then call it with echo $field i believe.

any ideas?

overrider

Posted

Hi, this works for me. If the text field you want to send has paragraph returns in it then it needs to be converted - something to do with using unix return marks etc, not 100% sure of the correct explanation, but it also hase to be done when calling Visual Basic commandss from within applescript.

code:________________________________________

--this ON statement converts the line endings

on ConvertLineEndings(thefield)

set oldelim to AppleScript's text item delimiters

try

set theLines to paragraphs of thefield

set AppleScript's text item delimiters to {return}

set thefield to theLines as string

set AppleScript's text item delimiters to oldelim

on error

set AppleScript's text item delimiters to oldelim

end try

end ConvertLineEndings

-- this is an example text field

set thefield to "blah blah blah

blah blah blah

blah blah blah"

set thefieldconvert to my ConvertLineEndings(thefield)

set thescript to "echo " & thefieldconvert & "| mail - s'test' [email protected]"

do shell script thescript

end of code__________________________________________

If you want to get the text field from filemaker then just replace the SET THEFIELD line with:

Tell app filemaker pro"

tell document 1

set thefield to cell "thetext"

end tell

end tell

there are probably better ways to do this but i hope its of some help.

Posted

there was a space after the mail command, it must look like mail -s though, so that was the reason for the "No mail for admin" message. however, after correcting this, it send an email, but not with the contents of the field i specified. so i had to take out all the converting parts, cause i did not understand them. in the end, this script worked for me, sending an email with the contents of the field i specified.




set thefield to cell "somefield" of current record of current layout

set thescript to "echo " & thefield & "| mail -s 'test' [email protected]"

do shell script thescript



however, this does not take care of linebreaks yet, as pointed out, but i cant fix it.

  • 3 months later...
Posted

Hi there,

Just noticed this post and was wondering if it is at all possible to use the OSX smtp server to do all of this but to also add attachments to the email and even possibly multiple attachments to build a kind of mini email client.

Any help on this would be greatly appreciated.

Regards,

Mark Bowen

This topic is 7039 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.