AutoHotkey Community

It is currently May 27th, 2012, 11:38 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 32 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject:
PostPosted: November 16th, 2009, 7:43 am 
Offline

Joined: August 24th, 2005, 5:29 pm
Posts: 549
Location: Berlin / Germany
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 :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 16th, 2009, 2:58 pm 
Offline

Joined: August 16th, 2009, 2:02 pm
Posts: 20
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 :oops:
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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 32 posts ]  Go to page Previous  1, 2, 3

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], bowen666 and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group