Consulting

Results 1 to 4 of 4

Thread: email extract

  1. #1

    email extract

    Hello,
    how can i extract sender surname with macro from received mail(oulook 2010) (example: name.surname.bla.bla.bla ) if subject is match and paste it to web textbox to search(let's say google)
    Thanks

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Moderator Bump
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    I can see that this problem is little challenging,how about alternative:

    Create rule in outlook if mail comes with specific subject , run excel that extracts complete email address of sender and compare it with existing list in column then copy cell with surname and paste it into google


    email Name Surname
    john.doe.bla.bla.bla John Doe

  4. #4
    Your later question just adds more complexity to the issue.

    Grabbing the sender from a message is simple. Writing that sender data to a web form is the issue and that remains true for your second question. However as your second message suggests that you want to run a Google search, you could use the following.

    SearchSender can be used from an Outlook rule and you can test the macro on a selected message using the TestMacro.

    If you want to access text boxes in other web sites then you are going to have to research writing to web pages.


    Option Explicit
    Private pWebAddress As String
    #If Win64 Then
    Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _
                                                                                          ByVal lpOperation As String, ByVal lpFile As String, _
                                                                                          ByVal lpParameters As String, ByVal lpDirectory As String, _
                                                                                          ByVal nShowCmd As Long) As Long
    #Else
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _
                                                                                  ByVal lpOperation As String, ByVal lpFile As String, _
                                                                                  ByVal lpParameters As String, ByVal lpDirectory As String, _
                                                                                  ByVal nShowCmd As Long) As Long
    #End If
    
    Public Sub TestMacro()
    Dim olMsg As MailItem
        On Error Resume Next
        Set olMsg = ActiveExplorer.Selection.Item(1)
        SearchSender olMsg
    lbl_Exit:
        Exit Sub
    End Sub
    
    Public Sub SearchSender(olitem As MailItem)
       pWebAddress = "https://www.google.com/search?q=" & olitem.SenderName
       Call NewShell(pWebAddress, 3)
    lbl_Exit:
        Exit Sub
    End Sub
    
    Private Sub NewShell(cmdLine As String, lngWindowHndl As Long)
        ShellExecute lngWindowHndl, "open", cmdLine, "", "", 1
    lbl_Exit:
        Exit Sub
    End Sub
    Last edited by gmayor; 03-25-2018 at 03:41 AM.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •