-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
749 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{A129029C-4AD4-4A96-BF2D-2CE5A360BD47}</ProjectGuid> | ||
<OutputType>WinExe</OutputType> | ||
<RootNamespace>EmailAddressExtracter</RootNamespace> | ||
<AssemblyName>EmailAddressExtracter</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
<PublishUrl>publish\</PublishUrl> | ||
<Install>true</Install> | ||
<InstallFrom>Disk</InstallFrom> | ||
<UpdateEnabled>false</UpdateEnabled> | ||
<UpdateMode>Foreground</UpdateMode> | ||
<UpdateInterval>7</UpdateInterval> | ||
<UpdateIntervalUnits>Days</UpdateIntervalUnits> | ||
<UpdatePeriodically>false</UpdatePeriodically> | ||
<UpdateRequired>false</UpdateRequired> | ||
<MapFileExtensions>true</MapFileExtensions> | ||
<ApplicationRevision>0</ApplicationRevision> | ||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion> | ||
<IsWebBootstrapper>false</IsWebBootstrapper> | ||
<UseApplicationTrust>false</UseApplicationTrust> | ||
<BootstrapperEnabled>true</BootstrapperEnabled> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Deployment" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Windows.Forms" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Form1.cs"> | ||
<SubType>Form</SubType> | ||
</Compile> | ||
<Compile Include="Form1.Designer.cs"> | ||
<DependentUpon>Form1.cs</DependentUpon> | ||
</Compile> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<EmbeddedResource Include="Form1.resx"> | ||
<DependentUpon>Form1.cs</DependentUpon> | ||
</EmbeddedResource> | ||
<EmbeddedResource Include="Properties\Resources.resx"> | ||
<Generator>ResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
<SubType>Designer</SubType> | ||
</EmbeddedResource> | ||
<Compile Include="Properties\Resources.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
</Compile> | ||
<None Include="Properties\Settings.settings"> | ||
<Generator>SettingsSingleFileGenerator</Generator> | ||
<LastGenOutput>Settings.Designer.cs</LastGenOutput> | ||
</None> | ||
<Compile Include="Properties\Settings.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Settings.settings</DependentUpon> | ||
<DesignTimeSharedInput>True</DesignTimeSharedInput> | ||
</Compile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> | ||
<Visible>False</Visible> | ||
<ProductName>.NET Framework 3.5 SP1</ProductName> | ||
<Install>false</Install> | ||
</BootstrapperPackage> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29102.190 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmailAddressExtracter", "EmailAddressExtracter.csproj", "{A129029C-4AD4-4A96-BF2D-2CE5A360BD47}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{A129029C-4AD4-4A96-BF2D-2CE5A360BD47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A129029C-4AD4-4A96-BF2D-2CE5A360BD47}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A129029C-4AD4-4A96-BF2D-2CE5A360BD47}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A129029C-4AD4-4A96-BF2D-2CE5A360BD47}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {391D2F2A-71D6-479E-B34C-D34D6698C939} | ||
EndGlobalSection | ||
EndGlobal |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Diagnostics; | ||
using System.Drawing; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
|
||
namespace EmailAddressExtracter | ||
{ | ||
public partial class Form1 : Form | ||
{ | ||
public Form1() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
OpenFileDialog ofd = new OpenFileDialog(); | ||
|
||
private void ChooseFileButton_Click(object sender, EventArgs e) | ||
{ | ||
|
||
if(ofd.ShowDialog() == DialogResult.OK) | ||
{ | ||
fileSelectionBox.Text = ofd.FileName; | ||
extractEmailButton.Enabled = true; | ||
downloadEmailAddressButton.Enabled = false; | ||
} | ||
} | ||
|
||
ProcessStartInfo startInfo = new ProcessStartInfo(); | ||
|
||
private void ExtractEmailAddressButton_Click(object sender, EventArgs e) | ||
{ | ||
MessageBoxButtons buttons = MessageBoxButtons.OK; | ||
if (!ofd.CheckFileExists) | ||
{ | ||
MessageBox.Show("Invalid file", "test", buttons); | ||
return; | ||
} | ||
startInfo.FileName = "grep.exe"; | ||
startInfo.RedirectStandardOutput = true; | ||
startInfo.UseShellExecute = false; | ||
startInfo.CreateNoWindow = true; | ||
startInfo.Arguments = "-a -o -P \"(?<name>[\\w.]+)\\@(?<domain>\\w+\\.\\w+)(\\.\\w+)?\" " | ||
+ '"' + ofd.FileName +'"'; | ||
|
||
Console.WriteLine("Grep arguments: " + startInfo.Arguments); | ||
using (Process process = Process.Start(startInfo)) | ||
{ | ||
using (StreamReader reader = process.StandardOutput) | ||
{ | ||
string result = reader.ReadToEnd(); | ||
emailListView.View = View.Details; | ||
emailListView.GridLines = true; | ||
emailListView.Columns.Add("Email", -2, HorizontalAlignment.Left); | ||
string[] emails = result.Split('\n'); | ||
Console.WriteLine("emails Count" + emails.Length.ToString()); | ||
foreach(string x in emails) | ||
{ | ||
emailListView.Items.Add(x); | ||
} | ||
if(emails.Length > 0) | ||
{ | ||
emailCountLabel.Text = "Email Count: " + emails.Length; | ||
downloadEmailAddressButton.Enabled = true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
SaveFileDialog sfd = new SaveFileDialog(); | ||
|
||
private void DownloadEmailAddressButton_Click(object sender, EventArgs e) | ||
{ | ||
sfd.Title = "Save Emails"; | ||
sfd.Filter = "CSV|*.csv"; | ||
if(sfd.ShowDialog() == DialogResult.OK) | ||
{ | ||
using (Stream myStream = sfd.OpenFile()) | ||
{ | ||
using(StreamWriter sw = new StreamWriter(myStream)) | ||
foreach (ListViewItem item in emailListView.Items) | ||
{ | ||
sw.WriteLine(item.Text.Trim()); | ||
} | ||
MessageBox.Show("Download Complete"); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.