Macro to move an email into a public folder

G

Guest

Eric posted a macro regarding moving an email into a folder. Eric, you are
truly an Outlook VBA genius!

This macro is very close to what I need. Here is what this inept Outlook
VBA person needs (that's me!)

In the subject line of a message a number will exist that represents a
public folder name. For example the subject line of the email message might
be ABC company 123.001. I want the macro to find the number and move the
message into the corresponding public folder name.
 
M

Michael Bauer

Hi,

you will need to know the format of the subject line. A little sample,
if you don´t know the position, but it´s sure that

a) only the part you are looking for is numeric
b) this numeric is a single word:

Public Sub Test()
Debug.Print FindFirstNumericInString("ABC company 123.001")
End Sub

Private Function FindFirstNumericInString(sSubject As String) As String
Dim i As Long
Dim avWords As Variant
Dim sMatch As String

avWords = Split(sSubject, " ")

For i = LBound(avWords) To UBound(avWords)
If IsNumeric(avWords(i)) Then
sMatch = avWords(i)
Exit For
End If
Next
FindFirstNumericInString = sMatch
End Function

And here you will find a function that allows you getting a folder by
it´s path:
http://www.outlookcode.com/d/code/getfolder.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top