Search through e-mail before sending in Outlook 2003

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cma2007
    New Member
    • Aug 2007
    • 1

    Search through e-mail before sending in Outlook 2003

    I'm trying to design code that will search for any 10 digit number in an e-mail after pressing the Send button in Microsoft Outlook 2003. I know that simply using the InStr() function would easily perform this if I had a specific string; however, I only want to look for 10 digit numbers. Here is what I'm trying to do:

    If InStr(1, Item.Body, TenNumber, vbTextCompare) > 0 Then
    <some condition>
    However, TenNumber doesn't have a specific value.

    I was thinking of using the Len() function to check for a string length of 10, and then using the IsNumeric() function to make sure it's a number (even though it's really a string). The only problem with this is that I don't know how to search through an e-mail to look for a string of length 10.

    Any ideas???
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by cma2007
    I'm trying to design code that will search for any 10 digit number in an e-mail after pressing the Send button in Microsoft Outlook 2003. I know that simply using the InStr() function would easily perform this if I had a specific string; however, I only want to look for 10 digit numbers. Here is what I'm trying to do:

    If InStr(1, Item.Body, TenNumber, vbTextCompare) > 0 Then
    <some condition>
    However, TenNumber doesn't have a specific value.

    I was thinking of using the Len() function to check for a string length of 10, and then using the IsNumeric() function to make sure it's a number (even though it's really a string). The only problem with this is that I don't know how to search through an e-mail to look for a string of length 10.

    Any ideas???
    I knew this would come handy someday. This is an old code I worked with, did not work for me but I think you may find it useful. You will need to some work a bit to get to do exactly what you need, like getting it to grab anything that mathes a 10 character criteria:

    [CODE=vb]

    Private Sub Command1_Click( )
    Dim objFSO, objFile, strContents, i, intLength, strLines
    Const ForReading = 1

    Set objFSO = CreateObject("S cripting.FileSy stemObject")
    Set objFile = objFSO.OpenText File("C:\Test.t xt", ForReading)

    strContents = objFile.ReadAll
    objFile.Close

    i = False

    Do Until i = True

    intLength = Len(strContents )
    If intLength <= 10 Then
    Exit Do
    End If
    End If
    strLines = strLines & Left(strContent s, 10) & vbCrLf
    strContents = Right(strConten ts, intLength - 10)

    Loop

    Text1.Text = strContents

    End Sub

    [/CODE]

    Comment

    Working...