Hi
I found this macro
Export Email Addresses - VBOffice
Pls help in modifying the macro that only @domain.xx will be written in the filePrivate Const SenderFile As String = "c:\email addresses\senders.txt" 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 Public Sub ExportSenderAddresses() On Error GoTo ERR_HANDLER Dim Sel As Outlook.Selection Dim Addresses As String Dim File As String Dim Hnd As Long Set Sel = Application.ActiveExplorer.Selection Addresses = GetSenderAddresses(Sel) If Len(Addresses) Then Hnd = FreeFile Open SenderFile For Append As #Hnd Print #Hnd, Addresses; Close #Hnd ShellExecute 0, "open", SenderFile, "", "", 1 End If Exit Sub ERR_HANDLER: If Hnd Then Close #Hnd MsgBox Err.Description End Sub Private Function GetSenderAddresses(Sel As Outlook.Selection) As String Dim b As String Dim obj As Object Dim i As Long For i = 1 To Sel.Count Set obj = Sel(i) If TypeOf obj Is Outlook.MailItem Or _ TypeOf obj Is Outlook.MeetingItem Then b = b & obj.SenderEmailAddress & vbCrLf End If Next GetSenderAddresses = b End Function
In combination with this:
Auto Block Unwanted Emails with the Blacklist in a Text File (vbaexpress.com)
It could be a great solution to fighting spam!
What do you think?
UPS!
When i insert the macro to module 4 this happens
ERROR ROT.jpg
What is wrong??
![]()




Reply With Quote