Click here to Skip to main content
15,895,746 members
Articles / Programming Languages / C#

A C# Implementation of Mime De/encode

Rate me:
Please Sign up or sign in to vote.
4.00/5 (16 votes)
21 Aug 2005CPOL 151.2K   4.2K   38  
A C# implementation of Mime de/encode
using System;
using System.Text;
using System.Collections;

namespace MIME
{
	/// <summary>
	/// 
	/// </summary>
	public class MimeMessage : MIME.MimeBody
	{
		public MimeMessage()
		{
			// 
			// TODO: Add constructor logic here
			//
		}

		// set/get RFC 822 message header fields
		public void SetFrom(string from, string charset)
		{
			SetFieldValue("From", from, charset);
		}
		public string GetFrom()
		{
			return GetFieldValue("From");
		}

		public void SetTo(string to, string charset)
		{
			SetFieldValue("To", to, charset);
		}
		public string GetTo()
		{
			return GetFieldValue("To");
		}

		public void SetCC(string cc, string charset)
		{
			SetFieldValue("CC", cc, charset);
		}
		public string GetCC()
		{
			return GetFieldValue("CC");
		}

		public void SetBCC(string bcc, string charset)
		{
			SetFieldValue("BCC", bcc, charset);
		}
		public string GetBCC()
		{
			return GetFieldValue("BCC");
		}

		public void SetSubject(string subject, string charset)
		{
			SetFieldValue("Subject", subject, charset);
		}
		public string GetSubject()
		{
			return GetFieldValue("Subject");
		}

		public void SetDate(string date, string charset)
		{
			SetFieldValue("Date", date, charset);
		}
		public void SetDate()
		{
			string dt = DateTime.Now.ToString("r",System.Globalization.DateTimeFormatInfo.InvariantInfo);
			dt = dt.Replace("GMT",DateTime.Now.ToString("zz",System.Globalization.DateTimeFormatInfo.InvariantInfo)+"00");
			SetFieldValue("Date",dt , null);
		}
		public string GetDate()
		{
			return GetFieldValue("Date");
		}

		public void Setversion()
		{
			SetFieldValue(MimeConst.MimeVersion, "1.0", null);
		}

	}
}

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
China China
I think I have to start coding my life now...Smile | :)

Comments and Discussions