![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
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 |