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

VBscript to pull the first 3 lines out of Outlook email messages



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 16th 06, 07:32 PM posted to microsoft.public.outlook.program_vba
scriptnewbie
external usenet poster
 
Posts: 2
Default VBscript to pull the first 3 lines out of Outlook email messages

I am a script newbie here. and I was wondering if any experts out there
would help me with a script to pull the first 3 lines of all outlook
email messages out of a folder and paste them to a text file. Say you
have a folder with AutoPreview showing only the first 3 lines of the
messages and you want to just pull those preview lines out. is it
possible to just pull these first 3 lines and paste them all to a text
file? Any help would much be appreciated. Thanks

Ads
  #2  
Old February 17th 06, 07:02 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default VBscript to pull the first 3 lines out of Outlook email messages

Am 16 Feb 2006 11:32:59 -0800 schrieb scriptnewbie:

This isn´t VBScript, but VBA. Maybe it helps despite of:

Public Sub CoolCode()
Dim obj as Object
Dim oMail as Outlook.MailItem
Dim oFld as Outlook.Mapifolder
Dim lLen as Long
Const FILE_NAME as String="c:\test.txt"

Set oFld=Application.Session.PickFolder
If Not oFld is Nothing Then
For Each obj in oFld.Items
If TypeOf obj is Outlook.MailItem Then
Set oMail=obj
lLen=GetPos(oMail.Body)
If lLen=0 Then lLen=Len(oMail.Body)
WriteFile FILE_NAME, Left$(oMail.Body, lLen), True
Endif
Next
Endif
End Sub

Private Sub WriteFile(sPath As String, _
sText As String, _
Optional ByVal bAppend As Boolean _
)
On Error GoTo AUSGANG
Dim lFileNr As Long

lFileNr = FreeFile
Select Case bAppend
Case False
Open sPath For Output As #lFileNr
Case Else
Open sPath For Append As #lFileNr
End If
Print #lFileNr, sText;

AUSGANG:
If lFileNr Then Close #lFileNr
If Err.Number Then Err.Raise &H800A0000 Or Err.Number, _
Err.Source, Err.Description, Err.HelpFile, Err.HelpContext
End Sub

Private Function GetPos(sBody as String) as Long
Dim i as Long
Dim pos as Long

pos=1
For i=1 To 3
pos=Instr(pos, sBody, vbCRLF)
If pos=0 Then
Exit For
Else
pos=pos+2
Endif
Next
GetPos=pos
End Function

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


I am a script newbie here. and I was wondering if any experts out there
would help me with a script to pull the first 3 lines of all outlook
email messages out of a folder and paste them to a text file. Say you
have a folder with AutoPreview showing only the first 3 lines of the
messages and you want to just pull those preview lines out. is it
possible to just pull these first 3 lines and paste them all to a text
file? Any help would much be appreciated. Thanks

  #3  
Old February 17th 06, 04:28 PM posted to microsoft.public.outlook.program_vba
scriptnewbie
external usenet poster
 
Posts: 2
Default VBscript to pull the first 3 lines out of Outlook email messages

Thanks Michael for your response!. I saved this script as VBs extension
and tried to run it. It could not go past line 2. It gave me an error
message "Expected end of statement" at line 2 character 11. Any idea
how to fix it? thanks

  #4  
Old February 18th 06, 09:48 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default VBscript to pull the first 3 lines out of Outlook email messages

Am 17 Feb 2006 08:28:39 -0800 schrieb scriptnewbie:

The almost only thing I know about VBS is that it doesn´t supports a type
declaration for variables.

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


Thanks Michael for your response!. I saved this script as VBs extension
and tried to run it. It could not go past line 2. It gave me an error
message "Expected end of statement" at line 2 character 11. Any idea
how to fix it? thanks

 




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
VBscript support Outlook forms Peter S Outlook - Installation 0 March 6th 06 04:15 PM
How do I print a month calendar from Outlook 2002 with grid lines Timmy! Outlook - Calandaring 3 March 3rd 06 04:23 PM
Slow pull down menu within the insert file dialog box Harold Outlook - General Queries 0 January 26th 06 04:00 PM
open outlook data files from vbscript / macro? Mad Scientist Jr Outlook and VBA 2 January 24th 06 10:20 PM
Outlook automatic folder categorization with shifting of the whole correspondence into the new built subfolder - VBScript needed Michael Bauer Outlook and VBA 0 January 9th 06 07:00 AM


All times are GMT +1. The time now is 06:10 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.