System.Net.Smtp.SmtpAttachment.GetMimeType C# (CSharp) Method

GetMimeType() public method

public GetMimeType ( ) : String
return String
		public String GetMimeType()
		{
			String mimeType = "application/unknown";
			string extension = Path.GetExtension(FileName);

			if (extension == null) return mimeType;

			String fileExtension = extension.ToLower();
			Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(fileExtension);
			if (regKey != null && regKey.GetValue("Content Type") != null)
			{
				mimeType = regKey.GetValue("Content Type").ToString();
			}

			return mimeType;
		}