-
Outlook express help
Hey guys, I'm new to the forum.
Nice to meet everyone. Seems like a friendly informative place.
I'm sort of new to VB. I did some work back in college with VB but on a very small basis. I basically just interfaced with an advantech card and read byte inputs and performed some byte outputs to read data from a series of sensors.
I recently started a new job and was asked to develop a small app for Outlook Express to do the following:
(1)Import a list of names of businesses from a txt document. These names are seperated by commas.
[vba]Sub LoadCustomers()
Dim Customers As String 'Creating a string to store the customers file initally
Dim tempArray As Variant 'Creating an array to store the individual customers
Dim customerArray(100) As String
Dim i As Integer ' Just a counter
Dim notFound(100) As String 'Creating an array of strings to store the names of CU's that did not submit a process summary
Open "C:\CU.txt" For Input As #1 ' Opening the Customers folder, these will be used as search keywords
Line Input #1, Customers 'Assigning the customers file to input #1 and storing the data in Customers string for later
Debug.Print Customers 'Debugging, shows what we imported
Close #1 'Closing the line input #1[/vba]
(2) The next logical step was to store this information in array like so:
[vba]tempArray = Split(Customers, ",") 'Splitting the customers string based on the comma delimiter
i = 0 'Init i as 0
Do While i < UBound(tempArray) 'Do until you find the end of the array
customerArray(i) = tempArray(i) 'Copy from the variant to the string array
i = i + 1 'increment counter
Loop 'loop[/vba]
(3)Using this array of strings I wanted to do the following with it:- Perform a search in the inbox and all subfolders of the inbox for each name. If an e-mail is found, great, move on to the next step. If not, add the customers name to the array of strings "notFound()"
- Once I have located an e-mail with the customers name in the header search the body for the a line of text "Process Summaries". This line is ALWAYS in the first line of the e-mail. If this text is NOT found, add the customers name to the "notFound()" array.
- Once I have performed this search on each name in the array I would like to create a string "output" and concat each name in the array to this string seperated by commas and report that no e-mail was found from these customers using a MsgBox().
I thought this would be a fairly straight forward process but I was shocked by the amount of syntax that came with this process. I have been combing through the help document and reading up on the objects but I'm having a terrible time doing anything with this.
Can anyone help me with performing a search and actually doing something with the results?
I wrote the following:
[vba]
Sub PerformSearch()
Dim olApp As Outlook.Application
Set olApp = New Outlook.Application
Dim newSearch As Search 'creating a new search
Const stringHeader As String = "urn:schemas:mailheader:subject = 'RE'" 'searching the header for the subject line 'RE'
Const stringFolders As String = "Inbox" 'Setting the folder to perform the search
Const stringTag As String = "HeaderSearch" 'Setting a tag for this search
Set newSearch = Application.AdvancedSearch(Scope:=stringFolders, Filter:=stringHeader, SearchSubFolders:=True, tag:=stringTag)
'Performing search ^^
End Sub
Sub ReturnResults(newSearch)
Dim newResults As Results 'creating a new result
MsgBox "The following search: " & newSearch.tag & " has completed." 'Displaying a message to show that the search was completed
Set newResults = newSearch.Results 'setting the results
Debug.Print newResults.count 'Debugging
For Each Item In newResults 'Printing the items supposedly
Debug.Print Item 'Debugging
Next 'Next result
Dim count As Long 'Creating an object of type long called count
count = newResults.count 'setting count to the results of our search
If count < 1 Then 'If there were no reults display a message box alerting the me
MsgBox ("No results were returned")
End If
End Sub[/vba]
But it doesn't appear to do anything. At first I was managing to get "no results returned" message in the ReturnResults(newSearch) sub, then I tinkered with the code and didn't get anything back. Even when I was getting the "no results returned" I wasn't supposed to be getting it. (note: I know I'm only seraching for "RE" right now, this was just a test because I have about a million e-mails with RE in the header in my inbox)
I'm performing all of these searches and everything on an open outlook express window.
Can anyone point me in the right direction? I found very little information on Outlook Express VBA's on the internet and even then the code was so convoluted that I couldn't follow it.
Any websites to easy to follow reference material would be great. Even some tips on some of this would be appreciated. I normally only program in Java, but the task of connecting to and interfacing with Outlook Express was ridiculous. So I decided to go with a VBA since it's built right into Outlook Express.
Last edited by Farrell101; 10-29-2008 at 04:40 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules