Jump to content
Just nu i M3-nätverket

Behöver hjälp med lite "Basic"-problem. (Applescript)


pyd

Recommended Posts

Jag försöker använda "Mail" för att plocka ut lite variablar ur mail, och sen inserta dom in i en extern mysql-databas.

Allt är bra, så länge jag håller dom separerade.

Jag kan köra en INSERT-fråga mot databasen, och jag får fram informationen ur mailen.

 

Men jag vet inte hur jag får informationen ifrån checkMail() till mysql-biten :fundersam:

Mao så vill jag ersätta följande:

'en ticket' = theTicket

'2009-01-21 17:15:56' = theReceivedTime

 

All hjälp / guidning är uppskattad!

 

set mySQLList to {"/usr/local/mysql-5.1.30-osx10.5-x86/bin/", "/Library/mysql-5.1.30-osx10.5-x86/bin"}

repeat with i from 1 to the count of mySQLList
	try
		set theResult to do shell script (item i of mySQLList) & "mysql -V"
		set gPathToMySQL to (item i of mySQLList)
		set haveFound to true
		exit repeat
	end try
end repeat

set gmySQLCommand to gPathToMySQL & "mysql"

set theHost to "external_server"
set theUser to "userName"
set thePassword to "password"
set thePort to "3306"
set theDatabase to "database"
set theTable to "table"

set theLoginString to " -h " & theHost & " -u " & theUser & "  --password=" & thePassword
set dataBaseString to " -D " & "'" & theDatabase & "'"
set theCommand to gmySQLCommand & theLoginString & dataBaseString & " -e " & quote & "INSERT INTO recivedMail (sentTo,ticket,dateRecived) VALUES ('en@epostadress.se', 'en ticket', '2009-01-21 17:15:56'); " & quote
set theResult to ""

--display dialog theCommand
try
	set theResult to do shell script theCommand
on error errMsg
	--display dialog errMsg
	log ("ERROR!!!! " & errMsg)
end try
return theResult

on checkMail()
	tell application "Mail"
		set theSelection to selection
		set theMessage to item 1 of theSelection
		set theTicket to content of theMessage
		set theSentTime to date sent of theMessage
		set theReceivedTime to date received of theMessage
		return theTicket
		return theSentTime
		return theReceivedTime
	end tell
end checkMail

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...