Good morning,
I have been researching how to extract data from an .msg file into a text file and I have found some information which I was able to modify to achieve part of what I want, which is shown below:
So I've been able to extract the information from a single .msg file into a text file, which is fine so far, but I'm now at a bit of a standstill as I can't seem to work out how to use this code to run through a large volume of these .msg files [4,500 to be exact] and to extract that information into a text file.
Below is what the above code extracts into my test text file:
"From: noreply@vaillant.com
Sent: 26 June 2015 12:00
To: Naylor, Andy
Subject: Product Registration
First name: OPUS TRUSTEES
Surname:
Street & Nr: F4 128 MOUNT STREET
City: LONDON
Postcode: W1K 3ND,
Tel: 01992 560000
Mobile:
Email:
Do you have a voucher code?:
adddif:
Select a model: ecoTEC plus 624
serial numer (28 didgets): 21143800100116811300239238N5
DD-MM-YYYY Installation Date: 2015-06-11
Name:
Street:
Nr.:
Postcode: W1K 3ND,
Gas Safe Number (5/6 digits): 194105
Vaillant (Vaillant Group UK Limited) has appointed a third party service provider* (Service Provider) to
provide product registration and warranty administration services. The Service Provider may also offer
related protection cover to accompany Vaillant products. Vaillant and the Service Provider will use the
information you have given to provide the requested service and for administration, marketing, and
research purposes. Vaillant and the Service Provider would like to contact you about their respective
products and services by mail, telephone, email and/or other electronic messaging services.:
tc: 1
Vaillant and the Service Provider may also share your information with their other respective group
companies and selected third parties so that they may contact you by mail, telephone, email and/or
other electronic messaging services to tell you about offers, products or services which may be of
interest to you.:
John Lee
Scanning Operations Facilitator
Domestic & General"
Ideally what I would like to do is to extract the following information from each of the .msg files and place them as fixed width data in that text file:
So all those in bold print followed by a colon are the field names and the information to the right of those colons are the data I want to extract into my text file on a seperate line for each email message:
First name: OPUS TRUSTEES
Surname:
Street & Nr: F4 128 MOUNT STREET
City: LONDON
Postcode: W1K 3ND,
Tel: 01992 560000
Mobile:
Email:
Do you have a voucher code?:
adddif:
Select a model: ecoTEC plus 624
serial numer (28 didgets): 21143800100116811300239238N5
DD-MM-YYYY Installation Date: 2015-06-11
Name:
Street:
Nr.:
Postcode: W1K 3ND,
Gas Safe Number (5/6 digits): 194105
The field lengths would be as follows:
First name: 25 Characters
Surname: 25 Characters
Street & Nr: 30 Characters
City: 30 Characters
Postcode: 8 Characters
Tel: 15 Characters
Mobile: 15 Characters
Email: 50 Characters
Do you have a voucher code?: 3 Characters
adddif: 30 Characters
Select a model: 15 Characters
serial numer (28 didgets): 28 Characters
DD-MM-YYYY Installation Date: 10 Characters
Name: 30 Characters
Street: 30 Characters
Nr.: 30 Characters
Postcode: 8 Characters
Gas Safe Number (5/6 digits): 6 Characters
Any assistance would be most appreciated. By the way I am using Access 2000
Regards
John Lee
I have been researching how to extract data from an .msg file into a text file and I have found some information which I was able to modify to achieve part of what I want, which is shown below:
Code:
Function ReadmsgFile()
Dim OL: Set OL = CreateObject("Outlook.Application")
Dim Msg ':Set Msg= CreateObject("Outlook.MailItem")
Set Msg = OL.CreateItemFromTemplate("G:\Scan - Verify\eFlow\Dynamics\Vaillant\Old No DPA Printed\Product Registration (1).msg")
'MsgBox Msg.Subject
Msg.saveAs "G:\Scan - Verify\eFlow\Dynamics\Vaillant\Old No DPA Printed\test.txt", olDoc
'The above statement will save the contents of .msg file into the designate .txt file
Set OL = Nothing
Set Msg = Nothing
End Function
So I've been able to extract the information from a single .msg file into a text file, which is fine so far, but I'm now at a bit of a standstill as I can't seem to work out how to use this code to run through a large volume of these .msg files [4,500 to be exact] and to extract that information into a text file.
Below is what the above code extracts into my test text file:
"From: noreply@vaillant.com
Sent: 26 June 2015 12:00
To: Naylor, Andy
Subject: Product Registration
First name: OPUS TRUSTEES
Surname:
Street & Nr: F4 128 MOUNT STREET
City: LONDON
Postcode: W1K 3ND,
Tel: 01992 560000
Mobile:
Email:
Do you have a voucher code?:
adddif:
Select a model: ecoTEC plus 624
serial numer (28 didgets): 21143800100116811300239238N5
DD-MM-YYYY Installation Date: 2015-06-11
Name:
Street:
Nr.:
Postcode: W1K 3ND,
Gas Safe Number (5/6 digits): 194105
Vaillant (Vaillant Group UK Limited) has appointed a third party service provider* (Service Provider) to
provide product registration and warranty administration services. The Service Provider may also offer
related protection cover to accompany Vaillant products. Vaillant and the Service Provider will use the
information you have given to provide the requested service and for administration, marketing, and
research purposes. Vaillant and the Service Provider would like to contact you about their respective
products and services by mail, telephone, email and/or other electronic messaging services.:
tc: 1
Vaillant and the Service Provider may also share your information with their other respective group
companies and selected third parties so that they may contact you by mail, telephone, email and/or
other electronic messaging services to tell you about offers, products or services which may be of
interest to you.:
John Lee
Scanning Operations Facilitator
Domestic & General"
Ideally what I would like to do is to extract the following information from each of the .msg files and place them as fixed width data in that text file:
So all those in bold print followed by a colon are the field names and the information to the right of those colons are the data I want to extract into my text file on a seperate line for each email message:
First name: OPUS TRUSTEES
Surname:
Street & Nr: F4 128 MOUNT STREET
City: LONDON
Postcode: W1K 3ND,
Tel: 01992 560000
Mobile:
Email:
Do you have a voucher code?:
adddif:
Select a model: ecoTEC plus 624
serial numer (28 didgets): 21143800100116811300239238N5
DD-MM-YYYY Installation Date: 2015-06-11
Name:
Street:
Nr.:
Postcode: W1K 3ND,
Gas Safe Number (5/6 digits): 194105
The field lengths would be as follows:
First name: 25 Characters
Surname: 25 Characters
Street & Nr: 30 Characters
City: 30 Characters
Postcode: 8 Characters
Tel: 15 Characters
Mobile: 15 Characters
Email: 50 Characters
Do you have a voucher code?: 3 Characters
adddif: 30 Characters
Select a model: 15 Characters
serial numer (28 didgets): 28 Characters
DD-MM-YYYY Installation Date: 10 Characters
Name: 30 Characters
Street: 30 Characters
Nr.: 30 Characters
Postcode: 8 Characters
Gas Safe Number (5/6 digits): 6 Characters
Any assistance would be most appreciated. By the way I am using Access 2000
Regards
John Lee