In this article, you will learn how to create a spam filter on your mail application. You will also see how to filter your mail based on whether the mail tells about a particular topic or not.
- SpamFilterSample.zip
- SpamFilterSample
- HigLabo.Mail.SampleApplication
- HigLabo.Mail
- Async
- bin
- Debug
- Release
- HigLabo.Mail.dll
- HigLabo.Net.dll
- Newtonsoft.Json.dll
- Common
- HigLabo.Mail.csproj
- HigLabo.Mail.csproj.user
- HigLabo.Mail.csproj.vspscc
- Imap
- obj
- Pop3
- Properties
- Smtp
- HigLabo.Net
- bin
- Debug
- de
- es
- fr
- it
- ja
- ko
- ru
- zh-Hans
- zh-Hant
- Release
- de
- System.Xml.Linq.resources.dll
- es
- System.Xml.Linq.resources.dll
- fr
- System.Xml.Linq.resources.dll
- HigLabo.Net.dll
- HigLabo.Net.Silverlight.dll
- HigLabo.Net.WindowsPhone7.dll
- it
- System.Xml.Linq.resources.dll
- ja
- System.Xml.Linq.resources.dll
- ko
- System.Xml.Linq.resources.dll
- Newtonsoft.Json.dll
- Newtonsoft.Json.Silverlight.dll
- Newtonsoft.Json.WindowsPhone7.dll
- ru
- System.Xml.Linq.resources.dll
- System.Xml.Linq.dll
- zh-Hans
- System.Xml.Linq.resources.dll
- zh-Hant
- System.Xml.Linq.resources.dll
- Core
- Extensions
- HigLabo.Net.csproj
- HigLabo.Net.csproj.user
- HigLabo.Net.csproj.vspscc
- HigLabo.Net.Silverlight.csproj
- HigLabo.Net.Silverlight.csproj.user
- HigLabo.Net.Silverlight.csproj.vspscc
- HigLabo.Net.WindowsPhone7.csproj
- HigLabo.Net.WindowsPhone7.csproj.user
- HigLabo.Net.WindowsPhone7.csproj.vspscc
- Http
- OAuth
- obj
- Properties
- Socket
- Reference
- BayesianFilter.dll
- bin
- Debug
- Reference.dll
- Release
- HtmlAgilityPack.dll
- obj
- Debug
- TempPE
- Properties
- Reference.csproj
- Reference.csproj.user
- SpamFilterSample
- SpamFilterSample-noexe.zip
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.IO;
namespace HigLabo.Net
{
/// <summary>
///
/// </summary>
#if !SILVERLIGHT
[Serializable]
#endif
public class HttpRequestCommand
{
private WebHeaderCollection _Headers = new WebHeaderCollection();
/// <summary>
///
/// </summary>
public String Url { get; set; }
/// <summary>
///
/// </summary>
public HttpMethodName MethodName { get; set; }
/// <summary>
///
/// </summary>
public Boolean IsSendBodyStream { get; set; }
/// <summary>
///
/// </summary>
public WebHeaderCollection Headers
{
get { return _Headers; }
}
/// <summary>
///
/// </summary>
public String ContentType { get; set; }
/// <summary>
///
/// </summary>
public Stream BodyStream { get; private set; }
/// <summary>
///
/// </summary>
public Func<String, String> UrlEncodeFunction { get; set; }
/// <summary>
///
/// </summary>
/// <param name="url"></param>
public HttpRequestCommand(String url)
{
this.InitializeProperty();
this.Url = url;
}
/// <summary>
///
/// </summary>
/// <param name="url"></param>
/// <param name="methodName"></param>
public HttpRequestCommand(String url, HttpMethodName methodName)
{
this.InitializeProperty();
this.Url = url;
this.MethodName = methodName;
}
/// <summary>
///
/// </summary>
/// <param name="url"></param>
/// <param name="stream"></param>
public HttpRequestCommand(String url, Stream stream)
{
this.InitializeProperty();
this.Url = url;
this.MethodName = HttpMethodName.Post;
this.BodyStream = stream;
}
/// <summary>
///
/// </summary>
/// <param name="url"></param>
/// <param name="encoding"></param>
/// <param name="values"></param>
public HttpRequestCommand(String url, Encoding encoding, Dictionary<String, String> values)
{
this.InitializeProperty();
this.Url = url;
this.MethodName = HttpMethodName.Post;
this.ContentType = HttpClient.ApplicationFormUrlEncoded;
this.BodyStream = new MemoryStream(this.CreateRequestBodyData(encoding, values));
}
/// <summary>
///
/// </summary>
/// <param name="url"></param>
/// <param name="data"></param>
public HttpRequestCommand(String url, Byte[] data)
{
this.InitializeProperty();
this.Url = url;
this.MethodName = HttpMethodName.Post;
this.BodyStream = new MemoryStream(data);
}
private void InitializeProperty()
{
this.UrlEncodeFunction = HttpClient.UrlEncode;
this.MethodName = HttpMethodName.Get;
this.IsSendBodyStream = false;
}
/// <summary>
///
/// </summary>
/// <param name="encoding"></param>
/// <param name="values"></param>
/// <returns></returns>
public Byte[] CreateRequestBodyData(Encoding encoding, Dictionary<String, String> values)
{
StringBuilder sb = new StringBuilder(512);
var d = values;
if (d == null || d.Keys.Count == 0) { return new Byte[0]; }
foreach (var key in d.Keys)
{
sb.AppendFormat("{0}={1}&", key, this.UrlEncodeFunction(d[key]));
}
return encoding.GetBytes(sb.ToString());
}
/// <summary>
///
/// </summary>
/// <param name="encoding"></param>
/// <param name="values"></param>
public void SetBodyStream(Encoding encoding, Dictionary<String, String> values)
{
if (String.IsNullOrEmpty(this.ContentType) == true)
{
this.ContentType = HttpClient.ApplicationFormUrlEncoded;
}
var bb = this.CreateRequestBodyData(encoding, values);
this.BodyStream = new MemoryStream(bb);
this.IsSendBodyStream = true;
}
/// <summary>
///
/// </summary>
/// <param name="data"></param>
public void SetBodyStream(Byte[] data)
{
this.BodyStream = new MemoryStream(data);
this.IsSendBodyStream = true;
}
/// <summary>
///
/// </summary>
/// <param name="stream"></param>
public void SetBodyStream(Stream stream)
{
this.BodyStream = stream;
this.IsSendBodyStream = true;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.