Parse Values from Email Templates

Discussion in 'Programming/Scripts' started by dpicella, May 15, 2010.

  1. dpicella

    dpicella New Member

    I've got some emails in the form of .eml files where I want to parse out some values and insert them in a MySQL DB.

    For example.
    Code:
    TYPE: TEST
    FIRST_NAME: JOHN
    LAST_NAME: DOE
    VISIT_CODE: 999-99-9999
    AUTH: 9999999-99999
    BEGIN:VTIMEZONE
    TZID:(GMT-08.00) Pacific Time (US & Canada)/Tijuana
    X-MICROSOFT-CDO-TZID:13
    BEGIN:STANDARD
    DTSTART:16010101T020000
    TZOFFSETFROM:-0700
    TZOFFSETTO:-0800
    RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=11;BYDAY=1SU
    END:STANDARD
    BEGIN:DAYLIGHT
    DTSTART:16010101T020000
    TZOFFSETFROM:-0800
    TZOFFSETTO:-0700
    RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=2SU
    END:DAYLIGHT
    END:VTIMEZONE
    
    What is the best way to approach this? Any suggestions. I don't need to read the email boxes, I've already got that part handled, I just need to take something like the above text (which I already have in a string) and parse the values and insert.

    Perhaps Regex in PHP would be easiest.
     
  2. falko

    falko Super Moderator

Share This Page