 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
nick
Joined: 24 Aug 2005 Posts: 504 Location: Berlin / Germany
|
Posted: Mon Nov 16, 2009 7:43 am Post subject: |
|
|
Some working example (at least for me):
| Code: | #NoEnv
MailBody =
(Join`r`n
my company
221, Rev Road
1234 Swiss Town
Eine neue Bestellung ist eingetroffen.
Bestell-Informationen
Bestellnummer: xxxx
Bestelldatum: Wednesday, 11 November 2009
Bestellstatus:
Ihre Informationen
Rechungsadresse
Firma:
Name: Jane Doe
Adresse : 123, Some Road
Stadt : Swiss village
Postleitzahl : 4321
Land : CHE
Telefon : 012 345 67 89
Fax :
Email : jane.doe@example.com
Lieferadresse
Firma: Acme inc.
Name : Jane Doe
Adresse : 123, Some other Road
Apt. 6
Stadt : Big Swiss town
Postleitzahl : 4567
Land : CHE
Telefon : 039 345 67 89
Fax :
Bestellte Produkte
Anzahl Name Artikel-Nr. Preis Summe
1 widget xy-01-001 64.45 chf 64.45 chf
2 widgets xy-01-002aa 34.34 chf 34.34 chf
)
; Initialize items variables
R_ := R_Firma := R_Name := R_Adresse := R_Stadt := ""
L_ := L_Firma := L_Name := L_Adresse := L_Stadt := ""
B_ := "", B_Counter := 0
P := 1
; Search for items -------------------------------------------------------------
RXAdresse := "\s*Firma\s*:\s(?P<Firma>\V*)\s*Name\s*:\s*(?P<Name>\V*)\s*Adresse\s*:\s*(?P<Adresse>\V*\R?\V*)\s*Stadt\s*:\s*(?P<Stadt>\V*)"
RXArtikel := "m)^(?P<Anzahl>\d+).*?(?P<ArtikelNr>xy-\d+-\w+)"
Mail := MailBody ; should be Clipboard
P := RegExMatch(Mail, "Rechungsadresse" . RXAdresse, R_, P)
P := RegExMatch(Mail, "Lieferadresse" . RXAdresse, L_, P ? P + StrLen(R_) : 1)
If P := InStr(Mail, "Bestellte Produkte", 1, P ? P + StrLen(L_) : 1) {
While P := RegExMatch(Mail, RXArtikel, B_, P + StrLen(B_)) {
B_Anzahl%A_Index% := B_Anzahl
B_ArtikelNr%A_Index% := B_ArtikelNr
B_Counter := A_Index
}
}
; Remove trailing linefeeds from addresses
R_Adresse := RegExReplace(R_Adresse, "\R+$")
L_Adresse := RegExReplace(L_Adresse, "\R+$")
; Show variables
Msg := "Rechungsadresse:`n"
. "Firma: " . R_Firma . "`n"
. "Name: " . R_Name . "`n"
. "Adresse: " . R_Adresse . "`n"
. "Stadt: " . R_Stadt . "`n`n"
. "Lieferadresse`n"
. "Firma: " . L_Firma . "`n"
. "Name: " . L_Name . "`n"
. "Adresse: " . L_Adresse . "`n"
. "Stadt: " . L_Stadt . "`n`n"
. "Bestellte Produkte = " . B_Counter . "`n"
Loop, % B_Counter
Msg .= B_Anzahl%A_Index% . " - " . B_ArtikelNr%A_Index% . "`n"
MsgBox, % Msg
Return |
_________________ nick
denick @ http://de.autohotkey.com/forum/ |
|
| Back to top |
|
 |
TalksWithComputers
Joined: 16 Aug 2009 Posts: 20
|
Posted: Mon Nov 16, 2009 2:58 pm Post subject: |
|
|
| Anonymous wrote: | | TalksWithComputers wrote: | | I always get an error message when trying to run the while loop. | Are you using the most recent release of AHK? |
No, I ain't... yet
| Nick wrote: | | Some working example |
Lovely.
I've tested it on various order mails and it works! So cool! You just made someone very happy!
Phew...
Now for using the stuff in the real world... But I'll bug someone else with this.
Thanks again!
Boris |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|