Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .vs/CleanupMyMailbox/v16/.suo
Binary file not shown.
7 changes: 7 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ExpandedNodes": [
""
],
"SelectedNode": "\\CleanupMyMailbox.sln",
"PreviewInSolutionExplorer": false
}
Binary file added .vs/slnx.sqlite
Binary file not shown.
6 changes: 3 additions & 3 deletions CleanupMyMailbox/CleanupMyMailbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -24,7 +25,6 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
Expand All @@ -48,8 +48,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLine, Version=2.7.82.0, Culture=neutral, PublicKeyToken=5a870481e358d379, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineParser.2.7.82\lib\net461\CommandLine.dll</HintPath>
<Reference Include="CommandLine, Version=2.8.0.0, Culture=neutral, PublicKeyToken=5a870481e358d379, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineParser.2.8.0\lib\net461\CommandLine.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Exchange.WebServices, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Exchange.WebServices.2.2\lib\40\Microsoft.Exchange.WebServices.dll</HintPath>
Expand Down
16 changes: 16 additions & 0 deletions CleanupMyMailbox/CleanupMyMailbox.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartArguments>--email cityoffayetteville%40ci.fay.nc.us --v --mailbox "inbox" --age 375 --defaultcredentials --x</StartArguments>
</PropertyGroup>
<PropertyGroup>
<PublishUrlHistory />
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>
23 changes: 19 additions & 4 deletions CleanupMyMailbox/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ public class Options
[Option('a', "age", Required = true, HelpText = "The age of emails after which they should be deleted. This should be a string that the .NET TimeSpan.Parse() method will recognize. For example: 1 = 1 day, 6:30 = 6 hours and 30 minutes")]
public TimeSpan Age { get; set; }

[Option('x', "deletemode", Required = false, HelpText = "Sets the Delete mode to Hard Delete. Emails will not go into Deleted Items folders")]
public bool DeleteMode { get; set; }

[Option('n', "noprompt", Required = false, HelpText = "Do not prompt before deleting emails")]
public bool NoPrompt { get; set; }



public override string ToString()
{
StringBuilder sb = new StringBuilder();
Expand Down Expand Up @@ -85,6 +90,7 @@ public void Run()
if (!string.IsNullOrWhiteSpace(_options.MailboxPath))
{
pathParts.AddRange(_options.MailboxPath.Split(new char[] { '/' }));

}
if (0 == pathParts[0].ToUpper().CompareTo("INBOX"))
{
Expand Down Expand Up @@ -120,7 +126,15 @@ public void Run()
{
Console.Write(".");
}
item.Delete(DeleteMode.MoveToDeletedItems);
if (_options.DeleteMode)
{
item.Delete(DeleteMode.HardDelete);
}
else
{
item.Delete(DeleteMode.MoveToDeletedItems);
}

}

Echo((_options.Verbose ? "Finished" : "\r\nFinished"));
Expand All @@ -129,14 +143,15 @@ public void Run()

private Folder GetFolder(List<string> path)
{
FolderId parentId = new FolderId(WellKnownFolderName.Inbox, _options.Email);
// First get the INBOX
Echo("Binding to INBOX", true);
Folder fInbox = Folder.Bind(_service, WellKnownFolderName.Inbox);

Folder fInbox = Folder.Bind(_service, parentId);

if (null != path && 0 < path.Count)
{
FolderId parentId = fInbox.Id;
Folder result = null;
Folder result = null;

foreach (string sPath in path)
{
Expand Down
Binary file not shown.
6 changes: 6 additions & 0 deletions CleanupMyMailbox/bin/Debug/CleanupMyMailbox.exe.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
</configuration>
Binary file added CleanupMyMailbox/bin/Debug/CleanupMyMailbox.pdb
Binary file not shown.
Binary file added CleanupMyMailbox/bin/Debug/CommandLine.dll
Binary file not shown.
Loading