mat-hh schrieb:
Hallo Jochen,
ich wollte mal nachfragen, wann du die AppleScripts zur Ansteuerung von Filemaker über Entourage veröffentlichst. Danke schon einmal im voraus.
Also erstmal der Weg Filemaker->Entourage:
1. Hier mal die felddefinition in Filemaker (Ergebnistyp natürlich Text), um in ein Feld einen lauffähigen AppleScript-code reinzuschreiben:
"set bpfad to ""Macintosh HD:Users:<user>
ocuments:<RestDesPfades>:""" & "¶" &
Wenn(Vorkasse="Ja";
"set att1 to (bpfad & """ & Adressen::MailAttachmentFileRumpf & "-" & (Adressen::AnzahlGesendeteMails-1) & ".pdf" & """)¶" &
"set attfile1 to alias att1" & "¶" &
"set att2 to (bpfad & """ & Adressen::MailAttachmentFileRumpf & "-" & Adressen::AnzahlGesendeteMails & ".pdf" & """)¶" &
"set attfile2 to alias att2" & "¶" &
"set attlist to {attfile1,attfile2}" & "¶";
"set att1 to (bpfad & """ & Adressen::MailAttachmentFile & """)¶" &
"set attfile1 to alias att1" & "¶" &
"set attlist to {attfile1}" & "¶")
&
"set newRec to """ & eMailwenn & """¶" &
"set newSubject to """ & MailSubject & """¶" &
"set newMailtext to the clipboard as text" & "¶" &
"tell application ""Microsoft Entourage""" & "¶" &
" set newMessage to make new outgoing message with properties {attachment:attlist, recipient:newRec, encoding:base64, use Windows file names:true, subject:newSubject, content:newMailtext}" & "¶" &
" send newMessage with sending later" & "¶" &
"end tell"
Dann 2. das, was letztlich in diesem Feld steht (zum Vergleich):
set bpfad to "Macintosh HD:Users:<user>
ocuments:<RestDesPfades>:"
set att1 to (bpfad & "huber-979-1.pdf")
set attfile1 to alias att1
set att2 to (bpfad & "huber-979-2.pdf")
set attfile2 to alias att2
set attlist to {attfile1,attfile2}
set newRec to "kurt.huber@t-online.de" -- ist hier nur ein Dummyname
set newSubject to "Ihre Bestellung; Auftragsbestätigung und Rechnung"
set newMailtext to the clipboard as text
tell application "Microsoft Entourage"
set newMessage to make new outgoing message with properties {attachment:attlist, recipient:newRec, encoding:base64, use Windows file names:true, subject:newSubject, content:newMailtext}
send newMessage with sending later
end tell
3. Jetzt der Weg, auf dem eingehende Mail von entourage nach Filemaker übertragen werden (Achtung, etwas längerer Text, trotzdem nur in Ausschnitten, daher *so nicht lauffähig*!!):
global email, nname, vname, titel, str, plz, ort, tel, fax, menge, artcode, firma, land, info, bestinfo
set text item delimiters to {}
set NKCount to 0
set PosCount to 0
set na to 0
set astring to "Aktualisierung"
set nb to 0
set bstring to "Bestellung"
set nr to 0
set rstring to "Registrierung"
set bpfad to "Macintosh HD:Users:<user>
ocuments:<RestDesPfades>"
set n to 0
set bestfolder to bpfad & ":Grafik:Website:data1:"
set bestfolderlist to (list folder bestfolder without invisibles)
-- zunächst analysieren, wieviele Mails von welchem Typ
tell application "Microsoft Entourage"
try
set mlist to selection
repeat with m in mlist
set sub to (get subject of m)
set read status of m to read
if sub = astring then set na to na + 1
if sub = bstring then set nb to nb + 1
if sub = rstring then set nr to nr + 1
end repeat
if (nb + nr) = 0 then display dialog "Eine verwendbare Auswahl an Mails wurde nicht erkannt." buttons {"OK"} default button 1
if na > 0 then display dialog "Die Aktualisierung(en) bitte manuell vornehmen." buttons {"OK"} default button 1
on error
display dialog "Eine verwendbare Auswahl an Mails wurde nicht erkannt." buttons {"OK"} default button 1
end try
end tell
-- dann die Registrierungen abarbeiten
-- (hier weggelasssen)
-- dann die Bestellungen abarbeiten
if nb > 0 then
set posfilename to "Positionen"
set posfilespec to bestfolder & posfilename
if posfilename is in bestfolderlist then tell application "Finder" to delete alias posfilespec -- ggf. altes File von letztem Mal löschen
set posfile to (open for access file posfilespec with write permission)
repeat with m in mlist
tell application "Microsoft Entourage" to set sub to (get subject of m)
if sub = bstring then
set email to ""
set menge to ""
set artcode to ""
set bestinfo to ""
tell application "Microsoft Entourage" to set mtext to paragraphs of (get content of m)
set BestinfoSection to false
repeat with zeile in mtext
if BestinfoSection then -- dann evtl. mehrzeilige Bestellinfo einlesen; damit aufhören, wenn nächster Abschnitt kommt
if (zeile starts with "agbcheck:") or (zeile starts with "emm:") then
set BestinfoSection to false
else
set bestinfo to bestinfo & return & zeile
end if
else
set zl to (length of zeile)
if zeile contains ":" and zl > ((offset of ":" in zeile) + 1) then
set zoffset to (offset of ":" in zeile)
set zinfo to (characters (zoffset + 2) thru zl of zeile) as string
set zinfo to cleanstring(zinfo)
if zeile begins with "email:" then
set email to zinfo
tell application "FileMaker Pro"
launch
open (bpfad & ":<Pfad>:Adressen")
do script "Alle aufrufen"
try
show (every record whose cell "email" contains ("\"" & email & "\""))
on error
--Dialogfenster mit Fehlermeldung
end try
end tell
end if
if zeile begins with "bp-" then -- das hier ist etwas Spezifisches, das nur für meine Website gilt
set artcode to (characters 4 thru ((offset of "|" in zeile) - 1) of zeile) as string
set menge to zinfo
tell me to WriteToPosFile(posfile) -- Bestellposition wegschreiben
set PosCount to PosCount + 1
end if
if zeile begins with "roaf:" then MoreBestInfo("Anzahl Flaschen", zinfo)
if zeile begins with "roap:" then MoreBestInfo("Anzahl Positionen", zinfo)
if zeile begins with "rovk:" then MoreBestInfo("Versandkosten", zinfo)
if zeile begins with "sabh:" then set bestinfo to bestinfo & return & "-SELBSTABHOLER ohne Versandkosten"
if zeile begins with "vork:" then set bestinfo to bestinfo & return & "-VORKASSE mit 2% Rabatt gewählt"
if zeile begins with "rorb:" then MoreBestInfo("Rechnungsbetrag", zinfo)
if zeile begins with "btext:" then -- Der BestellHinweisText kann mehrere Zeilen haben und ist erst mit "AGBCHECK on" definitiv zuende
MoreBestInfo("Besondere Hinweise", zinfo)
set BestinfoSection to true
end if
end if
end if
end repeat -- Mail zu Ende gelesen, Auswertung kann beginnen
tell application "FileMaker Pro"
launch
open (bpfad & ":<Pfad>:Adressen")
do script "Alle aufrufen"
try
show (every record whose cell "email" contains ("\"" & email & "\""))
set anzk to (the number of records) -- Anzahl Kunden mit dieser eMail-Adresse
if anzk = 1 then
set cell "Aktuelle Bestellinfo" of current record of database "Adressen" to bestinfo
set cell "email letzte Bestellung" of current record of database "Adressen" to email
else if anzk < 1 then
display dialog "Keinen Kunden mit eMail-Adresse '" & email & "' gefunden!" buttons {"OK"} default button 1
else
display dialog "Mehr als 1 Kunde mit eMail-Adresse '" & email & "' vorhanden!" buttons {"OK"} default button 1
end if
on error
--display dialog "error"
end try
end tell
end if
end repeat
close access posfile
if PosCount > 0 then
tell application "FileMaker Pro"
launch
open (bpfad & ":<Pfad>:Verkaufsdaten")
do script "Mail-Bestellpositionen importieren"
display dialog "Es wurden angelegt:" & return & "Bestellpositionen:" & tab & (PosCount as text) & return & "Neue Kunden:" & tab & (NKCount as text) buttons {"OK"} default button 1
open (bpfad & ":<Pfad>:Adressen")
do script "Alle aktuellen InetBestellungen suchen"
end tell
else
display dialog "Keine Bestellpositionen gefunden!" buttons {"OK"} default button 1
end if
end if
Das Ganze ist eine Mischung aus direktem Lesen und Schreiben aus AppleScript bzw. Entourage in Filemaker und einem aus Performancegründen eingeführten Erzeugen eines textfiles, das dann in FM importiert wird.
Einfach mal wirken lassen, you'll get the message.