bodylojohn
Registered User.
- Local time
- Today, 01:10
- Joined
- Dec 28, 2005
- Messages
- 205
Hello everybody....
In my application I can read mails from outlook.
I search for a specific keyword in a string (message) and then I retrieve the line.
Now I would like to search for a number that is always 6 digits long.
So in the line I would like to retrieve numbers from 000000 to 999999.
I found several pieces of code but none suffied.
I really hope you can help me in the right direction.
Thanks in advance.
The code I use to read the mails is:
The code I use to find the line I need:
So I would need to retrieve the 6 digits from Line.
In my application I can read mails from outlook.
I search for a specific keyword in a string (message) and then I retrieve the line.
Now I would like to search for a number that is always 6 digits long.
So in the line I would like to retrieve numbers from 000000 to 999999.
I found several pieces of code but none suffied.
I really hope you can help me in the right direction.
Thanks in advance.
The code I use to read the mails is:
Code:
Sub LoopThroughSQL()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
' Open the database
Set db = CurrentDb
' Define your SQL query
strSQL = "SELECT Onderwerp, Inhoud, Afzender FROM [Postvak IN] WHERE Afzender = 'E-mailgoedkeuring' AND Onderwerp LIKE '*keur de atv-formulier investeringen goed*';"
' Open a recordset based on the SQL query
Set rs = db.OpenRecordset(strSQL)
' Check if there are records returned by the query
If Not rs.EOF Then
rs.MoveFirst ' Move to the first record
' Loop through records
Do Until rs.EOF
' Access field values using rs.Fields("FieldName").Value
myText = rs.Fields("Inhoud").value
' Add more fields as needed
' Move to the next record
rs.MoveNext
Loop
Else
Debug.Print "No records found based on the query."
End If
' Close the recordset and database
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
The code I use to find the line I need:
Code:
Sub SearchAndStoreLine()
Dim searchText As String
Dim lines() As String
Dim line As Variant
' Sample text to search within
' myText = "This is line 1." & vbCrLf & _
' "This is line 2. It contains the keyword." & vbCrLf & _
' "This is line 3."
' Text to search for
searchText = "Verantwoordelijke kostenplaats"
' Split the text into an array of lines
lines = Split(myText, vbCrLf)
' Loop through each line
For Each line In lines
' Check if the searchText is present in the current line
If InStr(1, line, searchText, vbTextCompare) > 0 Then
' If found, store the entire line
Debug.Print "Line Found: " & line
MsgBox ("Line Found: " & line)
' You can store the line in another variable or perform other actions
End If
Next line
End Sub
So I would need to retrieve the 6 digits from Line.