Results 1 to 5 of 5
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329

    Searching Specific Text

    Hi guys, happy new year to you all on here



    The code below searches any email conversations absolutely perfect, i want to add something to search with any of the email conversations a specific value, ie any pricing agreements so i think because when the initial response goes out, there is a price offer so i am thinking of how to search for the £ sign within any part of the searchstring and return a message with £123.45 within any part of the email, is this easy to add to my code below ?? guessing there may need to be a sperate searchstring in the MailBody ??

    Code:
    Dim clEmail() As String, EmailAdd As String, MailBody As StringDim j As Integer
    Dim app As Object
    Dim SearchString As String
    
    
    MailBody = Me.txtMailMessage
    
    
    clEmail = Split(MailBody, vbCrLf)
    For j = 0 To UBound(clEmail)
    If InStr(1, clEmail(j), "Email Address:") > 0 Then
    EmailAdd = Mid(clEmail(j), 16)
    End If
    Next j
    
    
    Set app = GetObject(, "Outlook.Application")
    On Error GoTo 0
    If app Is Nothing Then
    Set app = CreateObject("Outlook.Application")
    app.Explorers.Add app.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
    app.Explorers(1).Activate
    End If
    SearchString = EmailAdd 'POSSIBLY ADD A 2nd PART OF SEACRH FOR POUND SIGN ??
    app.ActiveExplorer.Search SearchString, olSearchScopeAllFolders
    Set app = Nothing
    DoCmd.RunCommand acCmdAppMinimize

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    If Instr(1,MailBody,"L")>0 Then....?

    I can't easily make that character so I substituted L. I could have taken the time to retrieve it from a character map, but my coffee is calling for me...
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329
    HI micron, haha thank you, don't forget your coffee! i will try what you have suggested, thank you, my Cappuccino is awaiting assistance haha

  4. #4
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329
    Hi Guy's maybe i have done the wrong method here in finding a £ sign then returning the next characters but i have added the highlighted extra to post 1 just to see if i can return but nothing happens! is this a difficult task ?

    Code:
    Dim clEmail() As String, EmailAdd As String, MailBody As String
    Dim j As Integer
    Dim app As Object
    Dim SearchString As String, myValue As String
    
    
    MailBody = Me.txtMailMessage
    
    
    clEmail = Split(MailBody, vbCrLf)
    For j = 0 To UBound(clEmail)
    If InStr(1, clEmail(j), "Email Address:") > 0 Then
    EmailAdd = Mid(clEmail(j), 16)
    End If
    Next j
    
    
    Set app = GetObject(, "Outlook.Application")
    'On Error GoTo 0
    If app Is Nothing Then
    Set app = CreateObject("Outlook.Application")
    app.Explorers.Add app.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
    app.Explorers(1).Activate
    End If
    SearchString = EmailAdd
    app.ActiveExplorer.Search SearchString, olSearchScopeAllFolders
    Set app = Nothing
    DoCmd.RunCommand acCmdAppMinimize
    If InStr(1, MailBody, "£") > 0 Then
    myValue = Mid(MailBody, InStr(1, MailBody, "£"), 7)
    MsgBox (myValue)
    End If

  5. #5
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    I see that I overlooked you were after a currency amount as well, not just the symbol. Sorry about that. Did you step through this code and watch what happens (basic trouble shooting)? It works for me if I eliminate anything to do with Outlook.
    What if the figure, including the currency symbol, is not 7 characters?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 11-25-2019, 11:54 AM
  2. Replies: 17
    Last Post: 03-30-2018, 02:54 AM
  3. Replies: 17
    Last Post: 08-09-2016, 07:15 AM
  4. Replies: 6
    Last Post: 07-27-2015, 10:23 AM
  5. Replies: 7
    Last Post: 06-06-2013, 10:32 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
  •  
Other Forums: Microsoft Office Forums