sending emails whithout opening mail.app

any ideas for sending emails with display dialogs? I know how to display, and make a text field. but like it asked who to send it to then have a discription area (text to type whatever) then send email.

Have a look at this Scripting Addition: http://osaxen.com/files/xmail3.7.html

Good scripting
Farid

-- Repeat this loop until the text entered has been changed from the default example text.
repeat
	set theResult to display dialog "To whom would you like to send this message?" default answer "Example: Jane Doe"
	set theName to text returned of theResult
	if (theName does not start with "Example:") then
		exit repeat
	end if
end repeat

-- Repeat this loop until the text entered has been changed from the default example text.
-- Email address validation could be done at this point.
repeat
	set theResult to display dialog "What is their email address?" default answer "Example: janedoe@example.com"
	set theAddress to text returned of theResult
	if (theAddress does not start with "Example:") then
		exit repeat
	end if
end repeat

-- Prompt for message subject
set theResult to display dialog "What would you like the subject of the message to be?" default answer "I'm sending this via AppleScript!"
set theSubject to text returned of theResult

-- Prompt for whether an attachment is desired. If so, prompt for the location of the file.
set theResult to display dialog "Would you like to attach some files to this message?" buttons {"Yes", "No"} default button 1
set wantsAttachment to button returned of theResult
if wantsAttachment is equal to "Yes" then
	set theAttachment to choose file
end if

-- Prompt for message body
set theResult to display dialog "What would you like to say in the body of the message?" default answer ""
set theBody to text returned of theResult

-- Display a list of all the user's defined signatures. Skip if no signatures are defined.
tell application "Mail" to set everySignature to name of every signature
set theSignature to ""
if (count of everySignature) is greater than 0 then
	set everySignature to {"None"} & everySignature
	set theResult to choose from list everySignature with prompt ¬
		"Select a signature to use with this message:" default items {"None"} without multiple selections allowed
	if theResult is not equal to false then
		tell application "Mail" to set theSignature to signature (item 1 of theResult)
	end if
end if

-- Go through each account and constuct a list of possible addresses
-- to use as a return address for this message.
tell application "Mail"
	set listOfSenders to {}
	set everyAccount to every account
	repeat with eachAccount in everyAccount
		set everyEmailAddress to email addresses of eachAccount
		if (everyEmailAddress is not equal to missing value) then
			repeat with eachEmailAddress in everyEmailAddress
				set listOfSenders to listOfSenders & {(full name of eachAccount & " <" & eachEmailAddress & ">") as string}
			end repeat
		end if
	end repeat
end tell

-- Prompt the user to select which account to send this message from.
set theResult to choose from list listOfSenders with prompt ¬
	"Which account would you like to send this message from?" without multiple selections allowed
if theResult is not equal to false then
	set theSender to item 1 of theResult
	tell application "Mail"
		-- Properties can be specified in a record when creating the message or
		-- afterwards by setting individual property values.
		set newMessage to make new outgoing message with properties {subject:theSubject, content:theBody & return & return}
		tell newMessage
			-- Default is false. Determines whether the compose window will
			-- show on the screen or whether it will happen in the background.
			set visible to true
			set sender to theSender
			make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
			tell content
				if (wantsAttachment is equal to "Yes") then
					-- Position must be specified for attachments
					make new attachment with properties {file name:theAttachment} at after the last paragraph
				end if
			end tell
			if (theSignature is not equal to "") then
				set message signature to theSignature
			end if
		end tell
		-- Bring the new compose window to the foreground, in all its glory
		activate
	end tell
end if

There’s an example, but, i want it to ask me the first part of an email. admin@gmail.com
in this case admin is the first part.

I understood from the title of your post that you didn’t want to open Mail.app … ? :rolleyes:

Ciao
Farid

yep… i just got that from /Library/Scripts/MailScripts
http://bbs.macscripter.net/post.php?tid=27516
I’m not to good reading dictionaries of applescript.
But i posted the 1 from the Mail scripts folder because i want the Display DIalogs to show and ask who to send it to. BUt i want it to know the @ part.

I see. Do I suppose correctly that the address part after the “@” is not always the same? (Otherwise it would be quite trivial to add the first part, inserted by the user, to “@gmail.com” and save the result string in a variable…)
So if the domain-string is not constant and you want your script “to guess” that “peterpan” corrisponds to “peterpan@mac.com” and “admin” to “admin@gmail.com” - how could it do this without using some kind of database (Mail.app’s internal one, or a database created especially for this script…) ?

Ciao
Farid