what if I only want to read the first line of an email? (1 Viewer)

cursedeye

Registered User.
Local time
Today, 03:27
Joined
Oct 7, 2009
Messages
50
I want Access to read the fresh part of an email but not the old replied content.

What i mean is I want Access to only read the 'fresh' part of the email, for example 33333333333333 in this case.


3333333333333333

On Fri, Nov 13, 2009 at 4:11 PM, BBC <BBC@gmail.com> wrote:
2222222222222222

On Fri, Nov 13, 2009 at 4:11 PM, ADD <ADD@gmail.com> wrote:
1111111111111111




But I couldn't find a way to do it...sad...

Now I'm thinking if I can let Access only read the first line of an email.

is there any way to do it?


MY CODE:
Private Sub ReadInboxDone()
Dim TempRst As DAO.Recordset
Dim rst As DAO.Recordset
Dim OlApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim Mailobject As Object
Dim db As DAO.Database
Dim dealer As Integer

On Error GoTo ErrorHandler

DoCmd.RunSQL "Delete * from tbl_outlooktempFinish"
Set db = CurrentDb

Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetDefaultFolder(olFolderInbox)
Set TempRst = CurrentDb.OpenRecordset("tbl_OutlookTempFinish")
'
Set InboxItems = Inbox.Items
'
For Each Mailobject In InboxItems
If Mailobject.UnRead Then
With TempRst
.AddNew
!Subject = Mailobject.Subject
!from = Mailobject.SenderName
!to = Mailobject.to
!Body = Mailobject.Body
!DateSent = Mailobject.SentOn
!DateReceived = Mailobject.ReceivedTime
.Update
If Mailobject.Body Like "done*" Then
Mailobject.UnRead = False
Else
Mailobject.UnRead = True

End If
End With
End If
Next

ErrorHandler:
Set OlApp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set Mailobject = Nothing
Set TempRst = Nothing

End Sub
 

Zaeed

Registered Annoyance
Local time
Today, 16:27
Joined
Dec 12, 2007
Messages
383
Checkout the TextStream Object..
It contains a ReadLine method
 

ajetrumpet

Banned
Local time
Today, 01:27
Joined
Jun 22, 2007
Messages
5,638
wow, that's a tough one. try to maybe use the html body to see the element code in it i wonder? if matt's suggestion doesnt work.
 

cursedeye

Registered User.
Local time
Today, 03:27
Joined
Oct 7, 2009
Messages
50
I still can't get this work.

can any one help me.

I'm not sure where do I put the textstream part

Private Sub ReadInboxNA()
Dim TempRst As DAO.Recordset
Dim rst As DAO.Recordset
Dim OlApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim Mailobject As Object
Dim db As DAO.Database
Dim dealer As Integer
Dim workorder As Integer

Dim myFSO As New FileSystemObject
Dim myTextStream As TextStream


On Error GoTo ErrorHandler

DoCmd.RunSQL "Delete * from tbl_outlooktempNA"
Set db = CurrentDb

Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetDefaultFolder(olFolderInbox)
Set TempRst = CurrentDb.OpenRecordset("tbl_OutlookTempNA")

'
Set InboxItems = Inbox.Items
'



For Each Mailobject In InboxItems




If Mailobject.UnRead And (Mailobject.Body Like "*on Vacation*" Or Mailobject.Body Like "*not available*") Then
With TempRst

Set myTextStream = myFSO.OpenTextFile(Mailobject.Body, 1)
strLine = myTextStream.ReadLine
myTextStream.Close



.AddNew
!Subject = Mailobject.Subject
!from = Mailobject.SenderName
!to = Mailobject.to
!Body = Mailobject.Body
!DateSent = Mailobject.SentOn
!DateReceived = Mailobject.ReceivedTime
.Update

Mailobject.UnRead = False

End With
End If
Next

ErrorHandler:
Set OlApp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set Mailobject = Nothing
Set TempRst = Nothing

End Sub
 

Zaeed

Registered Annoyance
Local time
Today, 16:27
Joined
Dec 12, 2007
Messages
383
Ok, after a bit of playing i've come up with the following method that works..

Code:
position = 0
 
 
Do Until (Split(Mailobject.Body, vbCrLf)(position) <> "")
    position= position + 1
Loop
 
MsgBox(Split(Mailobject.Body, vbCrLf)(position))


The Split function breaks Mailobject.Body up into individual lines based on the position of vbCrLf.
If you wanted, you could create an array of lines, and then display the line you want..

Code:
dim textArray() as String
 
textArray = Split(Mailobject.Body, vbVrLf)
 
For position = 0 To UBound(textArray)
   msgbox(textArray(position))
Next



Hope this helps
 
Last edited:

Users who are viewing this thread

Top Bottom