A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Extract several lines of email messages starting from the end



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 16th 06, 08:57 PM posted to microsoft.public.outlook.program_vba
scriptnewbie
external usenet poster
 
Posts: 3
Default Extract several lines of email messages starting from the end

Hi everyone,

I was hoping that someone would give me an idea how to accomplish this.
I would like to pull out say the last 5 lines of all messages in my
Inbox folder and write them all to a text file. I was thinking about
creating a function and set a Position variable to the end of message,
but no success. I can get the first couple lines with the below
function. But how can I write my code to get the last 5 lines of the
messages. Thnx in advance for your help.

Private Function GetPosition(sBody As String) As Long
Dim p As Long
Dim position As Long
position = 1
For p = 1 To 5
position = InStr(position, sBody, vbCrLf)
position = position + 1
Next
GetPosition = position
End Function

  #2  
Old March 17th 06, 07:35 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default Extract several lines of email messages starting from the end

Am 16 Mar 2006 11:57:49 -0800 schrieb scriptnewbie:

You could search with InStrRev for vbCRLF backwards. For 5 lines you then
need to look for 6 vbCRLF (or 5 if the first of the 5 lines is also the
first line at all).

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Hi everyone,

I was hoping that someone would give me an idea how to accomplish this.
I would like to pull out say the last 5 lines of all messages in my
Inbox folder and write them all to a text file. I was thinking about
creating a function and set a Position variable to the end of message,
but no success. I can get the first couple lines with the below
function. But how can I write my code to get the last 5 lines of the
messages. Thnx in advance for your help.

Private Function GetPosition(sBody As String) As Long
Dim p As Long
Dim position As Long
position = 1
For p = 1 To 5
position = InStr(position, sBody, vbCrLf)
position = position + 1
Next
GetPosition = position
End Function

  #3  
Old March 17th 06, 11:45 AM posted to microsoft.public.outlook.program_vba
Klaus
external usenet poster
 
Posts: 7
Default Extract several lines of email messages starting from the end

You can also use this :

Private Function GetLines(ByVal text As String) As String()
Dim tb As New System.Windows.Forms.TextBox
tb.Multiline = True
tb.Text = text
Return tb.Lines
End Function

(Why do all the work by hand?)

Klaus

  #4  
Old March 17th 06, 04:13 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Extract several lines of email messages starting from the end

That, of course, assumes you're using VB.NET, which scriptnewbie did not say he was using.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Klaus" wrote in message oups.com...
You can also use this :

Private Function GetLines(ByVal text As String) As String()
Dim tb As New System.Windows.Forms.TextBox
tb.Multiline = True
tb.Text = text
Return tb.Lines
End Function

(Why do all the work by hand?)

Klaus

  #5  
Old March 17th 06, 06:23 PM posted to microsoft.public.outlook.program_vba
scriptnewbie
external usenet poster
 
Posts: 3
Default Extract several lines of email messages starting from the end

Thanks everyone for quick response! I am writing this script as a
macro for Outlook 2003. I am not using VB.Net at all.
Michael, could you elaborate your suggestion more? I am looking to get
the last 5 lines of the all email messages.

  #6  
Old March 18th 06, 08:58 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default Extract several lines of email messages starting from the end

Am 17 Mar 2006 09:23:59 -0800 schrieb scriptnewbie:

Instr searches forwards, InstrRev does it backwards. The rest you do know
already, just look for vbCRLF.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Thanks everyone for quick response! I am writing this script as a
macro for Outlook 2003. I am not using VB.Net at all.
Michael, could you elaborate your suggestion more? I am looking to get
the last 5 lines of the all email messages.

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract several lines of email messages starting from the end scriptnewbie Outlook and VBA 0 March 16th 06 08:57 PM
Why do I have split lines in email? Beemer Outlook - General Queries 2 March 13th 06 08:24 AM
VBscript to pull the first 3 lines out of Outlook email messages scriptnewbie Outlook and VBA 3 February 18th 06 10:48 AM
Why do all of my contact email address have SMTP at the end? Al S. Outlook - Using Contacts 1 February 7th 06 04:32 PM
How do I extract and use the info fields from "form mail" email to Sean Outlook - Using Forms 1 February 1st 06 12:53 AM


All times are GMT +1. The time now is 11:32 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.