Click here to Skip to main content
11,640,445 members (62,061 online)
Click here to Skip to main content
Articles » Languages » C# » General » Downloads
Add your own
alternative version

A C# Implementation of Mime De/encode

, 21 Aug 2005 CPOL 87.8K 3K 36
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)

Share

About the Author

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

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150731.1 | Last Updated 22 Aug 2005
Article Copyright 2005 by tauyoung
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid