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

Outlook 2003... search for line break char



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 25th 07, 01:06 PM posted to microsoft.public.outlook.program_vba
Ben Bradley
external usenet poster
 
Posts: 9
Default Outlook 2003... search for line break char

Hi everyone

I've got a folder full of website e-mail forms, so all the messages are
of the same format.
We're using Outlook 2003 in an Exchange environment.

I need to search through and find a particular set of messages that have
the following string:

double-sized listing?
Yes

Searching for just the string "double-sized listing?" won't work as all
the forms have that text.

The problem is I can't find a way to search for the line-break character.

In MS Word you can search for special characters... I would accomplish
the above search with the following...
double-sized listing?^NYes

But in Outlook that doesn't appear to work.

Is there a way to search for this in Outlook?
I assume there is a way, but I guess it might only be possible with VBA?


Next time I think we are going to have to re-design our e-mail form to
give the question and answer all on the one line.

Thanks
Ben
Ads
  #2  
Old September 25th 07, 01:22 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Outlook 2003... search for line break char

Yes, you'll need code to do that. If you're searching the Body property, look for vbCrLf.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Ben Bradley" wrote in message ...
Hi everyone

I've got a folder full of website e-mail forms, so all the messages are
of the same format.
We're using Outlook 2003 in an Exchange environment.

I need to search through and find a particular set of messages that have
the following string:

double-sized listing?
Yes

Searching for just the string "double-sized listing?" won't work as all
the forms have that text.

The problem is I can't find a way to search for the line-break character.

In MS Word you can search for special characters... I would accomplish
the above search with the following...
double-sized listing?^NYes

But in Outlook that doesn't appear to work.

Is there a way to search for this in Outlook?
I assume there is a way, but I guess it might only be possible with VBA?


Next time I think we are going to have to re-design our e-mail form to
give the question and answer all on the one line.

Thanks
Ben

  #3  
Old September 28th 07, 11:15 AM posted to microsoft.public.outlook.program_vba
Ben Bradley
external usenet poster
 
Posts: 9
Default Outlook 2003... search for line break char

Hi

Is there a complete example of the VBA script I need to complete this?
I'm completely new to VBA but that would give me a great starting point
to try some other searches of that nature.


Also, I guess I need to load the Outlook VBa addin off the CD?
We're using Outlook 2003.


Thanks
Ben




Sue Mosher [MVP-Outlook] wrote:
Yes, you'll need code to do that. If you're searching the Body property, look for vbCrLf.

  #4  
Old September 28th 07, 12:23 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Outlook 2003... search for line break char

VBA installs as part of the default setup. If you're completely new to it, start with the basics he http://outlookcode.com/article.aspx?id=49

Your macro (not script) would need to return the Inbox with GetDefaultFolder, then iterate over its Items collection, something like this:

Sub DoSearch()
Dim fld As Outlook.MAPIFolder
Dim itm As Object
Dim strFind As String
On Error Resume Next
Set fld = Application.Session.GetDefaultFolder(olFolderInbox )
strFind = "double-sized listing?" & vbCrLf & "Yes"
' or vbLf it's line feed not a complete CRLF
For Each itm In fld.Items
If InStr(1, Item.Body, strFind, vbTextCompare) 0 Then
MsgBox "You found one!"
End If
Next
Set itm = Nothing
Set fld = Nothing
End Sub

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Ben Bradley" wrote in message ...
Hi

Is there a complete example of the VBA script I need to complete this?
I'm completely new to VBA but that would give me a great starting point
to try some other searches of that nature.


Also, I guess I need to load the Outlook VBa addin off the CD?
We're using Outlook 2003.


Thanks
Ben




Sue Mosher [MVP-Outlook] wrote:
Yes, you'll need code to do that. If you're searching the Body property, look for vbCrLf.

"Ben Bradley" wrote in message ...
Hi everyone

I've got a folder full of website e-mail forms, so all the messages are
of the same format.
We're using Outlook 2003 in an Exchange environment.

I need to search through and find a particular set of messages that have
the following string:

double-sized listing?
Yes

Searching for just the string "double-sized listing?" won't work as all
the forms have that text.

The problem is I can't find a way to search for the line-break character.

In MS Word you can search for special characters... I would accomplish
the above search with the following...
double-sized listing?^NYes

But in Outlook that doesn't appear to work.

Is there a way to search for this in Outlook?
I assume there is a way, but I guess it might only be possible with VBA?


Next time I think we are going to have to re-design our e-mail form to
give the question and answer all on the one line.

Thanks
Ben

  #5  
Old October 1st 07, 10:47 AM posted to microsoft.public.outlook.program_vba
Ben Bradley
external usenet poster
 
Posts: 9
Default Outlook 2003... search for line break char

Hi Sue
Perfect. I got that code to work and the MsgBox repeatedly popped up on
the screen.

All the website form e-mails are in a particular sub-folder of my inbox.
So that worked.

Is there any way to generate an Outlook find results list of these messages?


Thanks so much for your help so far!
Ben


Sue Mosher [MVP-Outlook] wrote:
VBA installs as part of the default setup. If you're completely new to it, start with the basics he http://outlookcode.com/article.aspx?id=49

Your macro (not script) would need to return the Inbox with GetDefaultFolder, then iterate over its Items collection, something like this:

Sub DoSearch()
Dim fld As Outlook.MAPIFolder
Dim itm As Object
Dim strFind As String
On Error Resume Next
Set fld = Application.Session.GetDefaultFolder(olFolderInbox )
strFind = "double-sized listing?" & vbCrLf & "Yes"
' or vbLf it's line feed not a complete CRLF
For Each itm In fld.Items
If InStr(1, Item.Body, strFind, vbTextCompare) 0 Then
MsgBox "You found one!"
End If
Next
Set itm = Nothing
Set fld = Nothing
End Sub

  #6  
Old October 1st 07, 02:50 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Outlook 2003... search for line break char

Is there any way to generate an Outlook find results list of these messages?

You mean display them in the dialog for Advanced Find? Not programmatically. You'd need to provide your own display UI. Alternatively, use code to assign a category to those items that match your criteria, then search manually on that category.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Ben Bradley" wrote in message ...
Hi Sue
Perfect. I got that code to work and the MsgBox repeatedly popped up on
the screen.

All the website form e-mails are in a particular sub-folder of my inbox.
So that worked.

Is there any way to generate an Outlook find results list of these messages?


Thanks so much for your help so far!
Ben


Sue Mosher [MVP-Outlook] wrote:
VBA installs as part of the default setup. If you're completely new to it, start with the basics he http://outlookcode.com/article.aspx?id=49

Your macro (not script) would need to return the Inbox with GetDefaultFolder, then iterate over its Items collection, something like this:

Sub DoSearch()
Dim fld As Outlook.MAPIFolder
Dim itm As Object
Dim strFind As String
On Error Resume Next
Set fld = Application.Session.GetDefaultFolder(olFolderInbox )
strFind = "double-sized listing?" & vbCrLf & "Yes"
' or vbLf it's line feed not a complete CRLF
For Each itm In fld.Items
If InStr(1, Item.Body, strFind, vbTextCompare) 0 Then
MsgBox "You found one!"
End If
Next
Set itm = Nothing
Set fld = Nothing
End Sub

  #7  
Old October 1st 07, 04:44 PM posted to microsoft.public.outlook.program_vba
Ben Bradley
external usenet poster
 
Posts: 9
Default Outlook 2003... search for line break char

Ah ok.
That will still work I guess.

So in the VBA code, how do I flag a message a certain colour?

In this section of code:
For Each itm In fld.Items
If InStr(1, Item.Body, strFind, vbTextCompare) 0 Then
MsgBox "You found one!"
End If
Next


I need to change the...
MsgBox "You found one!"
line to set a flag colour for that message.

What's the VBA for that?


Also, is there a complete online reference of all VBA functions / commands?


Thanks
Ben


Sue Mosher [MVP-Outlook] wrote:
Is there any way to generate an Outlook find results list of these messages?


You mean display them in the dialog for Advanced Find? Not programmatically. You'd need to provide your own display UI. Alternatively, use code to assign a category to those items that match your criteria, then search manually on that category.

  #8  
Old October 1st 07, 05:06 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Outlook 2003... search for line break char

Take a look at the MailItem.FlagIcon property. The complete reference is in object browser -- F2 in VBA -- as well as on MSDN.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Ben Bradley" wrote in message ...
Ah ok.
That will still work I guess.

So in the VBA code, how do I flag a message a certain colour?

In this section of code:
For Each itm In fld.Items
If InStr(1, Item.Body, strFind, vbTextCompare) 0 Then
MsgBox "You found one!"
End If
Next


I need to change the...
MsgBox "You found one!"
line to set a flag colour for that message.

What's the VBA for that?


Also, is there a complete online reference of all VBA functions / commands?


Thanks
Ben


Sue Mosher [MVP-Outlook] wrote:
Is there any way to generate an Outlook find results list of these messages?


You mean display them in the dialog for Advanced Find? Not programmatically. You'd need to provide your own display UI. Alternatively, use code to assign a category to those items that match your criteria, then search manually on that category.

  #9  
Old October 2nd 07, 03:50 PM posted to microsoft.public.outlook.program_vba
Ben Bradley
external usenet poster
 
Posts: 9
Default Outlook 2003... search for line break char

Hi Sue
Thanks for all your help so far.
If all the e-mails are in a certain folder, how do I tell the script to
process just a particular sub-folder.

We're in an Exchange environment and the folder is located:
Inbox\BB Website Forms


This is what I've got so far:
Sub DoSearch()
Dim fld As Outlook.MAPIFolder
Dim itm As Object
Dim strFind As String
On Error Resume Next
Set fld = Application.Session.GetDefaultFolder(olFolderInbox )
strFind = "double-sized listing?" & vbCrLf & "Yes"
' or vbLf it's line feed not a complete CRLF
For Each itm In fld.Items
If InStr(1, Item.Body, strFind, vbTextCompare) 0 Then
'MsgBox "You found one!"
itm.FlagIcon = olYellowFlagIcon
itm.Save
End If
Next
Set itm = Nothing
Set fld = Nothing
End Sub



Thanks
Ben


Sue Mosher [MVP-Outlook] wrote:
Take a look at the MailItem.FlagIcon property. The complete reference is in object browser -- F2 in VBA -- as well as on MSDN.

  #10  
Old October 2nd 07, 08:31 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Outlook 2003... search for line break char

Every folder has a Folders collection that represents its subfolders. Each subfolder in a Folders collection must have a unique name. Hence, you can use fld.Folders("BB Website Forms").

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Ben Bradley" wrote in message ...
Hi Sue
Thanks for all your help so far.
If all the e-mails are in a certain folder, how do I tell the script to
process just a particular sub-folder.

We're in an Exchange environment and the folder is located:
Inbox\BB Website Forms


This is what I've got so far:
Sub DoSearch()
Dim fld As Outlook.MAPIFolder
Dim itm As Object
Dim strFind As String
On Error Resume Next
Set fld = Application.Session.GetDefaultFolder(olFolderInbox )
strFind = "double-sized listing?" & vbCrLf & "Yes"
' or vbLf it's line feed not a complete CRLF
For Each itm In fld.Items
If InStr(1, Item.Body, strFind, vbTextCompare) 0 Then
'MsgBox "You found one!"
itm.FlagIcon = olYellowFlagIcon
itm.Save
End If
Next
Set itm = Nothing
Set fld = Nothing
End Sub



Thanks
Ben


Sue Mosher [MVP-Outlook] wrote:
Take a look at the MailItem.FlagIcon property. The complete reference is in object browser -- F2 in VBA -- as well as on MSDN.

 




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
Outlook 2007: How to break vertical line in reply to message? [email protected] Outlook - General Queries 1 October 5th 07 09:15 PM
Outlook 2003... search for line break char Ben Bradley Outlook - General Queries 0 September 24th 07 04:29 PM
Outlook 2003 - Search folders - adding criteria to an old mail search? Dustin Emhart Outlook - General Queries 0 December 20th 06 02:39 PM
how do I break up a large attachment that I am sending in Outlook roger Outlook - Installation 1 April 19th 06 08:11 PM
How to input line break in the body of an email defined in vb. Xluser@work Outlook and VBA 1 February 22nd 06 02:20 PM


All times are GMT +1. The time now is 08:09 PM.


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.