megatronixs
Registered User.
- Local time
- Tomorrow, 00:43
- Joined
- Aug 17, 2012
- Messages
- 719
Hi all,
I created some code to read emails from Outlook and put text from a table in the email to the Access database.
Now I need to capture the participants from the email and create for each a new entry in the database.
It would need to go one by one of the participants name and add themm to the table.
In the table that is in the emails, it has 2 columns and 7 rows
first is for the Event ID, and the other 6 for the participants.
Any help on this?
Greetings.
I created some code to read emails from Outlook and put text from a table in the email to the Access database.
Now I need to capture the participants from the email and create for each a new entry in the database.
It would need to go one by one of the participants name and add themm to the table.
In the table that is in the emails, it has 2 columns and 7 rows
first is for the Event ID, and the other 6 for the participants.
Code:
Private Sub btn_process_enrolment_emails_Click()
'//--------- Dim and Set------------------------
Dim TempRst As DAO.Recordset
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim vText As Variant
Dim sText As String
Dim i As Long, j As Long
Dim rCount As Long
Dim strParameter As String
Dim strParamValue As String
Dim oItem As MailItem
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Set db = CurrentDb
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace("MAPI")
Set olFolder = objNS.GetDefaultFolder(olFolderInbox)
Set olFolder = olFolder.Folders("Training Team Enrolment")
Set TempRst = CurrentDb.OpenRecordset("tbl_enrolment")
For Each InboxItem In olFolder.Items
If InboxItem.Subject Like "RE: Training:*" Then
If InboxItem.UnRead Then
With TempRst
.AddNew
sText = InboxItem.Body
vText = Split(sText, Chr(13))
For i = UBound(vText) To 0 Step -1
vItem = Split(vText(i), Chr(9))
strParameter = ""
strParamValue = ""
On Error Resume Next
strParameter = Trim(Replace(vItem(0), Chr(10), ""))
strParamValue = Trim(vItem(1))
Select Case strParameter
Case "Event ID:"
!event_id = strParamValue
Case "Participant 1:"
!participant_name = strParamValue
' Case "Participant 2:"
'
' !participant_name = strParamValue
'
' Case "Participant 3:"
'
' !participant_name = strParamValue
'
' Case "Participant 4:"
'
' !participant_name = strParamValue
'
' Case "Participant 5:"
'
' !participant_name = strParamValue
'
' Case "Participant 6:"
'
' !training_duration = strParamValue
End Select
Next i
.Update
InboxItem.UnRead = False
InboxItem.FlagStatus = olFlagComplete
End With
End If
Set TempRst = Nothing
End If
Next
End Sub
Any help on this?
Greetings.