Log in

View Full Version : email extract



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

SamT
03-23-2018, 08:25 AM
Moderator Bump

loop66
03-25-2018, 02:22 AM
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.:clap:bla.bla.bla
John
Doe

gmayor
03-25-2018, 03:19 AM
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