Hello Everyone,
I am having trouble collecting bunch of information from an incoming mail!
I intend to use the collected information for creating another email that will be a translation of the first gathered information…
Here is a part example of the received mail If I get a hold on where I made a mistake I can finish my whole mail script…
Please find a new inquiry with file name: ZWMi1 Paper Post-it memo pad Tough I attached to this mail XXXXX
Our Description Post-it memo pad
Material(s): Paper
2mm hard-cover, with post-its in neon-colours like in picture below.
5x colour post-it strips/ please see picture for sizes/ 25 sheets
1x smaller post-it paper note/ about 50x70mm/ 25 sheets/ white
1x big post-it paper note /about 100x70mm/ 100 sheets/ white
Please find the temporary item number: PMP PAP 001
Quantity 1K or 5K
Here is my script which do not return anything sadly :(;-(
tell application "Mail"
set msg to selection
try
set msgcontent to content of msg
set msgid to message id of msg
set {originalSubject, originalProductName, originalMaterial, originalExtraDescription, originalQuantity, originalSizes, originalBodyColor, originalLogo, originalLogoDetails, originalAccessory, originalAccessoryInformation, originalDelivery, originalShipmentTo, originalSafetyTest} to my parseMsg(msgcontent)
my createEvent(originalSubject, originalProductName, originalMaterial, originalExtraDescription, originalQuantity, originalSizes, originalBodyColor, originalBodyColor, originalLogo, originalLogoDetails, originalAccessory, originalAccessoryInformation, originalDelivery, originalShipmentTo, originalSafetyTest)
end try
end tell
-- Parse the email content to extract movie details.
on parseMsg(msgcontent)
set originalSubject to extractBetween(msgcontent, "Please find a new inquiry with file name: ", "I attached to this mail the RLPS to be filed in the proper area in kiki.")
set originalProductName to extractBetween(msgcontent, "Our Description ", "Material(s): ")
set originalMaterial to extractBetween(msgcontent, "Material(s): ", " ")
set originalExtraDescription to extractBetween(msgcontent, originalMaterial, "Please find the temporary item number: ")
set originalQuantity to extractBetween(msgcontent, "Quantity ", "Size ")
set originalSizes to extractBetween(msgcontent, "Size ", "Body color ")
set originalBodyColor to extractBetween(msgcontent, "Body color ", "Logo ")
set originalLogo to extractBetween(msgcontent, "Logo ", "Logo position ")
set originalLogoDetails to extractBetween(msgcontent, "Logo position ", "Accessory ")
set originalAccessory to extractBetween(msgcontent, "Accessory ", "Extra information")
set originalAccessoryInformation to extractBetween(msgcontent, "Extra information", "Approximate delivery time: ")
set originalDelivery to extractBetween(msgcontent, "Approximate delivery time: ", "Place of delivery: ")
set originalShipmentTo to extractBetween(msgcontent, "Client Area: ", "Client Sea Port: ")
set originalSafetyTest to extractBetween(msgcontent, "Safety Test: ", "Type of product: ")
return {originalSubject, originalProductName, originalMaterial, originalExtraDescription, originalQuantity, originalSizes, originalBodyColor, originalLogo, originalLogoDetails, originalAccessory, originalAccessoryInformation, originalDelivery, originalShipmentTo, originalSafetyTest}
end parseMsg
-- Extract the substring from between two strings
to extractBetween(theString, startText, endText)
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to startText
set startComps to text items of theString
set AppleScript's text item delimiters to endText
set endComps to text items of second item of startComps
set AppleScript's text item delimiters to tid
return trim(first item of endComps)
end extractBetween
-- Trim all whitespace from start and end of a string
on trim(theString)
set theChars to {" ", tab, character id 10, return, character id 0, character id 8232}
repeat until first character of theString is not in theChars
set theString to text 2 thru -1 of theString
end repeat
repeat until last character of theString is not in theChars
set theString to text 1 thru -2 of theString
end repeat
return theString
end trim
Thanks for any help.