Parse --moved from Introductions

Hi

Thanks for the input but I have already added the extra fields. This was pointed out by mole in his original upload of the solution.

Many thanks :)
 
Hi Mike

I'm not going to try and improve on Moke's existing solution using Split function...
The reason I tried my approach using Excel Power Query was related to another topic currently being investigated (JSON files in Access).

Yesterday evening in post #14, I asked a couple of questions but you'd already logged off

For my own purposes it would still be helpful if you could supply another record with ALL 'destination' fields populated in the Contents field.
Is that possible?
Preferably in the original format - still unsure where line returns or | character was in the original

Alternatively (to save me the time & effort) could you provide the code used to get the data from Outlook in the first place as I've never needed to do that
 
Hi Colin

This Db is quite large so would take some time to extract the bits you would need.

Cheers

Mike
 
Hi Colin

The process of linking to Outlook is via the External data Wizard
 
Mike,
Can you provide say 4 or 5 records with at least 1 with all fields populated?
I think Moke's solution is a solid approach--but it's possible that some condition may ignore a "marker" in the code and bypass a field(pure guess on my part).
So a few records with different arrangements of fields with values and without may identify the issue.

Perhaps the issue is associated with moke's use of TownCity2 and postalcode2. I haven't checked, but noticed these names.

Just did a minor test. I added a Billing Address postalcode, K2J3L8
And changed the code as below

Code:
 'write the values to the table by there position in the array
    rs.AddNew
    rs!From = strWrite(0)
    rs!Subject = strWrite(1)
    rs!MessageBody = strWrite(2)
    rs!ContactName = strWrite(3)
    rs!Email = strWrite(4)
    rs!Phone = strWrite(5)
    rs!Organization = strWrite(6)
    rs!OrganizationAddress = strWrite(7)
    rs!TownCity = strWrite(8)
    rs!postcode = strWrite(9)
    rs!BillingAddress = strWrite(10)
   [COLOR="Red"][B] rs!TownCity2[/B][/COLOR] = strWrite(11)
    [COLOR="Red"][B]rs!postcode2[/B][/COLOR] = strWrite(12)
    rs!CourseTitle = strWrite(13)
    rs!CourseDate = strWrite(14)
    rs!NumberofParticipants = strWrite(15)
    rs!ParticipantNames = strWrite(16)
    rs!PONumber = strWrite(17)
    rs!AdditionalComments = strWrite(18)
    rs.Update


But a few more records would be useful for testing.
 
Last edited:
Sorry didnt notice the thread spread to page 2.

Jdraws probably on target. I only had your one example to go by but assumed that the data was coming from some type of form which had the catagory titles prepopulated, ie. Subject:,etc.

note that Subject: and Subject : (note the extra space in the latter) will not be picked up by the replace routine and could cause errors.

In the project I had which parsed a pdf with over 10,000 pages there was also an issue with non-printable characters but thats not likely your cause.

if the data is shifting it is probable that a title is not being replaced by a pipe.

the TownCity2 and postalcode2 were to avoid duplicate fields in the table.
 
your 2nd record is missing
Code:
PO Number: 
Additional Comments:
dietary requirements etc.
 -- 
 This e-mail was sent from a contact form on XXX (http://www.abcscotland.org.UK.gridhosted.co.UK)

thats causing a subscript out of range error

note that there are 20 elements to the array but only 19 written to the table. I didnt include the element after the "--". If there arent 20 elements you will get the error.
 
Last edited:
Moke123,
May I ask?, what is the reason for removing the From: element first?

TIA
 
In the form for table2 there is no Postal code for organizationAddress
and no TownCity2 or PostalCode2 for BilllingAddress.

Seems to be working with concocted sample records.

Myrecord2
Code:
From: Syanne Narrah  
Subject: Open Course Booking - Cooking with Odd Chemicals Fall 2017 - on account

 Message Body: This is the first announcement of this Course
Contact Name: Syanne Narrah

 Email: sn@btconnect.com <mailto:sn@btconnect.com>

Phone: 01995818818

Organization: Modern Cooking For Fun and Profit

Organization Address:
216 AppleCore Road

Town/City: Bolton

Postcode: B32 9AY
Billing Address: ABC Computing

Town/City: Bedford

Postcode: D5T 8KP

Course Title: Cooking with Odd Chemicals

Course Date: 11th October 2017

Number of Participants: 4

Participant Names: 
Ashley Brown
James Brown
Heeza Payne
Jerimiah Browne

PO Number: 234

Additional Comments:
dietary requirements etc.

 -- 
 This e-mail was sent from a contact form on XXX (http://www.abcscotland.org.UK.gridhosted.co.UK)
 

Attachments

  • mikeParseMyRecord.jpg
    mikeParseMyRecord.jpg
    77.1 KB · Views: 98
hi Gasman,
Moke123,
May I ask?, what is the reason for removing the From: element first?
since all the other titles are being replaced with pipes, if that was included in RepString then the resulting string would begin with a pipe rather than the "from:" value and strWrite(0) would always be empty. you could include it but i just wrote it that way. you would just have to adjust the strWrite postions in the .addnew section of the code.

if you add the lines indicated below you can see a little better whats going on in the immediate window

Code:
    'loop throught the string and make the replacements
    For i = 0 To UBound(strRep)
        strOut = Replace(strOut, strRep(i), "|")
    Next i

        'Add this line to see what strOut looks like
    Debug.Print "strOut = " & strOut

    strWrite = Split(strOut, "|")    'split the resulting string by the | character

        'Add these 3 lines to see how strWrite resolves
    For i = 0 To UBound(strWrite)
        Debug.Print Trim(strWrite(i)) & " = strWrite(" & i & ")"
    Next i

I also noticed that you should wrap the strWrites with trim
 
Hi JDraw

Can you zip the Db back to me so that I can compare ?

Many thanks for taking a look at this for me.:)
 
Mike,

I took moke's original and added a record 2 with new Contents data.
It is 99% his code. I did adjust his Form2 to show field values that weren't in his form.
Slight revision since last post.
The greenish/gray background is for Postal code of OrganizationAddress.
yellow background is for missing BillingAddress parts.

moke gets the credit for this - he did the work.
 

Attachments

Hi moke123

I added the bit of code to debug.Print the various sections and I notice that the
strOut section does not split correctly after the Phone Number which I have highlighted in Red

strOut = Debbie Whellans | Open Course Booking - Good Practice in Infection Control - 11/10/2017 - on account | | Debbie Whellans | cd@btconnect.com <mailto:cd@btconnect.com> | 01995813313 Organisation: Cd Nursery Organisation Address:1A Main Street | Bolton | xxx xxx | aa | aa | aa | Good Practice in Infection Control | 11th October 2017 | 1 | Ashley Brown Brian Jenkins | | dietary requirements etc. | This e-mail was sent from a contact form on XXX (http://xxx)
 
Hi Everyone

I have come to the conclusion that it must be the linked Outlook folder that is causing the problem.

I just tested the revised Db that JDraw supplied and it works just great.

I imported the 4 elements required :-
table1
table2
frmOne
frmTwo

When I run the Module I get the corruption on the strOut.

I am visiting the users on Wednesday and will see what the structure is on the Website that generates the EMails.

Will keep everyone updated.

many thanks for hanging in here with this one.
:):banghead:
 
thanks Jdraw, chalk that one up to cross posting.
i posted that on UA in my original upload
2nd edit: I just noticed on frmTwo I didnt include a couple fields but if you look in the table they are there.

mike,

01995813313 Organisation: Cd Nursery Organisation Address:1A Main Street

Organisation or Organization? its an American/British thing?
you may have to check the spelling in RepString.

Organisation and organization mean the same thing. They are alternate spellings of the same word, used primarily in British and American English, respectively. Organisation is the correct spelling in British English. Organization is the correct spelling in American English.

edit: My fault. Being an ignorant Yankee I think i changed the spelling when i was constructing example data as I thought it was misspelled.:o
 
Last edited:
Hi

Just come back to this and I'm slightly confused after skim reading all the posts going back & forth since my last post (#22).

For my own purposes (Excel Power Query parsing), is there a definitive version I can use with at least one complete record. If so, which one?

The process of linking to Outlook is via the External data Wizard

Thanks - that's all I needed to know
I've not used that for a long while & had forgotten how easy it was.
Just imported all my forum notifications into an Access table to try it out.
May run a modified version of moke's code on that lot
 
Last edited:
Hi moke

many many thanks for all of your guidance on this project which is now working as it should.

Thanks again :):)

Can you give me a quick guide on what I should do with the following structure where the first 2 lines are Blank.

From: Elise Kelman
Email Address:
Subject: [Open Course Individual Booking - Elementary Food Hygiene - 27/09/2017]

Message Body:
Name: Elise Kelman

Email Address: km@gmail.com<mailto:km@gmail.com>

Phone Number: 023456081614

Address:
4 Woodburn Road

Edinburgh
EH11 4DT

Course Title: Elementary Food Hygiene

Course Date: 27th September 2017

Additional Comments: dietary requirements etc.

--
This e-mail was sent from a contact form on Training For Care (http://www.tfcscotland.org.uk.gridhosted.co.uk)

I modified the Module as shown below but it constantly gives me the error Type miss-match ??

Any help appreciated:-

The Modified Module is as shown below:-

Public Function Replacements2(varString As String) As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String

Dim strRep As Variant
Dim strWrite As Variant
Dim RepString As String
Dim i As Integer
Dim strOut As String

strOut = Replace(varString, "From:", "", "EMail Address:", "") 'remove "From:" from the 0 position

'string of items to replace with |
RepString = "Subject:,Message Body:,Name:,Email Address:,Phone Number:,Address:,Course Title:,Course Date:,Additional Comments:,--"

strRep = Split(RepString, ",")

strOut = Replace(Replace(strOut, Chr(10), ""), Chr(13), " ") 'remove the carraige returns and line feeds

'loop throught the string and make the replacements
For i = 0 To UBound(strRep)
strOut = Replace(strOut, strRep(i), "|")
Next i
'Debug.Print strOut 'jjed for testing
strWrite = Split(strOut, "|") 'split the resulting string by the | character


strSql = "select * from TableIndividual1 where id = 0"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSql)

'write the values to the table by there position in the array
rs.AddNew
rs!From = strWrite(0)
rs!EmailAddress = strWrite(1)
rs!Subject = strWrite(2)
rs!MessageBody = strWrite(3)
rs!Name = strWrite(4)
rs!EmailAddress = strWrite(5)
rs!PhoneNumber = strWrite(6)
rs!Address = strWrite(7)
rs!CourseTitle = strWrite(8)
rs!CourseDate = strWrite(9)
rs!AdditionalComments = strWrite(10)
rs.Update

MyExit:
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
 
Can you give me a quick guide on what I should do with the following structure where the first 2 lines are Blank.
For clarity's sake with "From: Elise Kelman", I refer to "From:" as the title and "Elise Kelman" as the value. so when you say the first 2 lines are blank, do you mean the title, the value, or both?
 
For the sake of clarity, it IS possible to link to a non-default OutLook folder with VBA. It takes a bit of fancy coding but it is possible. It took me over a year and a whole gaggle of google searches, but I eventually got it sorted out.

If anyone is interested, I can provide the link to the thread...
 
Last edited:

Users who are viewing this thread

Back
Top Bottom