Click here to Skip to main content
15,884,099 members
Articles / Desktop Programming / ATL

En/Decode MIME-Content with MimeSniffer

Rate me:
Please Sign up or sign in to vote.
4.88/5 (26 votes)
2 Dec 20022 min read 372.9K   7K   74  
RFC-compliant Mime-En/Decoder
// MimeSniffer.idl : IDL source for MimeSniffer.dll
//

// This file will be processed by the MIDL tool to
// produce the type library (MimeSniffer.tlb) and marshalling code.

import "oaidl.idl";
import "ocidl.idl";

[
	uuid(FB7F3AA6-2C3F-4D1B-99B6-47016A01EE11),
	version(1.0),
	helpstring("MimeSniffer 1.0 Type Library")
]
library MIMESNIFFERLib
{
	importlib("stdole32.tlb");
	importlib("stdole2.tlb");

	typedef enum MajorMimeTypes
	{
		[helpstring("MajorMimeType Multipart")]		Multipart = 0,
		[helpstring("MajorMimeType Text")]			Text,
		[helpstring("MajorMimeType Image")]			Image,
		[helpstring("MajorMimeType Application")]	Application,
		[helpstring("MajorMimeType Audio")]			Audio,
		[helpstring("MajorMimeType Video")]			Video,
		[helpstring("MajorMimeType Message")]		Message
	} MajorMimeTypes;

	typedef enum MultipartTypes
	{
		[helpstring("Multipart MinorMimeType Mixed")]			Mixed = 0,
		[helpstring("Multipart MinorMimeType Parallel")]		Parallel,
		[helpstring("Multipart MinorMimeType Digest")]			Digest,	
		[helpstring("Multipart MinorMimeType Alternative")]		Alternative
	} MultipartTypes;


	typedef enum TextTypes
	{
		[helpstring("Text MinorMimeType Plain")]		Plain = 0,
		[helpstring("Text MinorMimeType Html")]			Html
	} TextTypes;

	typedef enum ImageTypes
	{
		[helpstring("Image MinorMimeType Gif")]			Gif = 0,
		[helpstring("Image MinorMimeType Jpeg")]		Jpg
	} ImageTypes;

	typedef enum ApplicationTypes
	{
		[helpstring("Application MinorMimeType Octet")]			OctetStream = 0,
		[helpstring("Application MinorMimeType Postscript")]	Postscript
	} ApplicationTypes;

	typedef enum AudioTypes
	{
		[helpstring("Audio MinorMimeType Basic")]		Basic = 0
	} AudioTypes;

	typedef enum VideoTypes
	{
		[helpstring("Video MinorMimeType Mpeg")]		Mpeg = 0
	} VideoTypes;

	typedef enum MessageTypes
	{
		[helpstring("Message MinorMimeType Rfc822")]		Rfc822 = 0,
		[helpstring("Message MinorMimeType Partial")]		Partial,
		[helpstring("Message MinorMimeType External")]		ExternalBody
	} MessageTypes;

	typedef enum EncoderTypes
	{
		[helpstring("EncoderType 7Bit")]				SevenBit = 0,
		[helpstring("EncoderType Quoted-Printable")]	QuotedPrintable,
		[helpstring("EncoderType Base64")]				Base64,	
		[helpstring("EncoderType 8Bit")]				EightBit,		
		[helpstring("EncoderType Binary")]				Binary
	} EncoderTypes;

	[
		object,
		uuid(D83F672E-B48F-4F92-9DBE-523C5079EC2D),
		dual,
		helpstring("IMimeDecoder Interface"),
		pointer_default(unique)
	]
	interface IMimeDecoder : IDispatch
	{
		[id(1), helpstring("method LoadFromFile")] HRESULT LoadFromFile([in] BSTR Path, [out,retval] VARIANT_BOOL* pbvarResult);
		[id(2), helpstring("method SaveToFile")] HRESULT SaveToFile([in] BSTR Path, [out,retval] VARIANT_BOOL* pbvarResult);
		[propget, id(3), helpstring("property ReturnPath")] HRESULT ReturnPath([out, retval] VARIANT *pVal);
		[propput, id(3), helpstring("property ReturnPath")] HRESULT ReturnPath([in] VARIANT newVal);
		[propget, id(4), helpstring("property MajorMimeVersion")] HRESULT MajorMimeVersion([out, retval] long *pVal);
		[propput, id(4), helpstring("property MajorMimeVersion")] HRESULT MajorMimeVersion([in] long newVal);
		[propget, id(5), helpstring("property MinorMimeVersion")] HRESULT MinorMimeVersion([out, retval] long *pVal);
		[propput, id(5), helpstring("property MinorMimeVersion")] HRESULT MinorMimeVersion([in] long newVal);
		[propget, id(6), helpstring("property ReplyTo")] HRESULT ReplyTo([out, retval] VARIANT *pVal);
		[propput, id(6), helpstring("property ReplyTo")] HRESULT ReplyTo([in] VARIANT newVal);
		[propget, id(7), helpstring("property From")] HRESULT From([out, retval] VARIANT *pVal);
		[propput, id(7), helpstring("property From")] HRESULT From([in] VARIANT newVal);
		[propget, id(8), helpstring("property Sender")] HRESULT Sender([out, retval] VARIANT *pVal);
		[propput, id(8), helpstring("property Sender")] HRESULT Sender([in] VARIANT newVal);
		[propget, id(9), helpstring("property ResentReplyTo")] HRESULT ResentReplyTo([out, retval] VARIANT *pVal);
		[propput, id(9), helpstring("property ResentReplyTo")] HRESULT ResentReplyTo([in] VARIANT newVal);
		[propget, id(10), helpstring("property ResentFrom")] HRESULT ResentFrom([out, retval] VARIANT *pVal);
		[propput, id(10), helpstring("property ResentFrom")] HRESULT ResentFrom([in] VARIANT newVal);
		[propget, id(11), helpstring("property ResentSender")] HRESULT ResentSender([out, retval] VARIANT *pVal);
		[propput, id(11), helpstring("property ResentSender")] HRESULT ResentSender([in] VARIANT newVal);
		[propget, id(12), helpstring("property Date")] HRESULT Date([out, retval] VARIANT *pVal);
		[propput, id(12), helpstring("property Date")] HRESULT Date([in] VARIANT newVal);
		[propget, id(13), helpstring("property ResentDate")] HRESULT ResentDate([out, retval] VARIANT *pVal);
		[propput, id(13), helpstring("property ResentDate")] HRESULT ResentDate([in] VARIANT newVal);
		[propget, id(14), helpstring("property To")] HRESULT To([out, retval] VARIANT *pVal);
		[propput, id(14), helpstring("property To")] HRESULT To([in] VARIANT newVal);
		[propget, id(15), helpstring("property CC")] HRESULT CC([out, retval] VARIANT *pVal);
		[propput, id(15), helpstring("property CC")] HRESULT CC([in] VARIANT newVal);
		[propget, id(16), helpstring("property BCC")] HRESULT BCC([out, retval] VARIANT *pVal);
		[propput, id(16), helpstring("property BCC")] HRESULT BCC([in] VARIANT newVal);
		[propget, id(17), helpstring("property Subject")] HRESULT Subject([out, retval] VARIANT *pVal);
		[propput, id(17), helpstring("property Subject")] HRESULT Subject([in] VARIANT newVal);
		[propget, id(18), helpstring("property MessageID")] HRESULT MessageID([out, retval] VARIANT *pVal);
		[propput, id(18), helpstring("property MessageID")] HRESULT MessageID([in] VARIANT newVal);
		[propget, id(20), helpstring("property ReceivedFieldAsRaw")] HRESULT ReceivedFieldAsRaw([out, retval] VARIANT_BOOL *pVal);
		[propput, id(20), helpstring("property ReceivedFieldAsRaw")] HRESULT ReceivedFieldAsRaw([in] VARIANT_BOOL newVal);
		[propget, id(21), helpstring("property ReturnReceiptTo")] HRESULT ReturnReceiptTo([out, retval] VARIANT *pVal);
		[propput, id(21), helpstring("property ReturnReceiptTo")] HRESULT ReturnReceiptTo([in] VARIANT newVal);
		[id(22), helpstring("method Load")] HRESULT Load([in] LPDISPATCH StreamObject, [out,retval] VARIANT_BOOL* pbvarRestult);
		[id(23), helpstring("method Save")] HRESULT Save([in] LPDISPATCH StreamObject, [out,retval] VARIANT_BOOL* pbvarRestult);
		[propget, id(24), helpstring("property SubjectRaw")] HRESULT SubjectRaw([out, retval] VARIANT *pVal);
		[propput, id(24), helpstring("property SubjectRaw")] HRESULT SubjectRaw([in] VARIANT newVal);
		[propget, id(25), helpstring("property Body")] HRESULT Body([out, retval] VARIANT *pVal);
		[propput, id(25), helpstring("property Body")] HRESULT Body([in] VARIANT newVal);
		[propget, id(112), helpstring("property CanUpdateName")] HRESULT CanUpdateName([out, retval] VARIANT_BOOL *pVal);
		[propput, id(113), helpstring("property UpdateName")] HRESULT UpdateName([in] BSTR newVal);
		[propget, id(114), helpstring("property InterpretEmbeddedMails")] HRESULT InterpretEmbeddedMails([out, retval] VARIANT_BOOL *pVal);
		[propput, id(114), helpstring("property InterpretEmbeddedMails")] HRESULT InterpretEmbeddedMails([in] VARIANT_BOOL newVal);
	};
	[
		uuid(9DA0E669-0034-4770-9D3F-C3ECC9A0124F),
		helpstring("_IMimeDecoderEvents Interface")
	]
	dispinterface _IMimeDecoderEvents
	{
		properties:
		methods:
		[id(1), helpstring("method OnError")] HRESULT OnError([in] BSTR strHint, [in] long Line);
	};
	[
		object,
		uuid(AF0FEF99-54D9-401F-8395-EECDF967AC99),
		dual,
		helpstring("IMailAddress Interface"),
		pointer_default(unique)
	]
	interface IMailAddress : IDispatch
	{
		[propget, id(1), helpstring("property Address")] HRESULT Address([out, retval] BSTR *pVal);
		[propput, id(1), helpstring("property Address")] HRESULT Address([in] BSTR newVal);
		[propget, id(2), helpstring("property NameRaw")] HRESULT NameRaw([out, retval] BSTR *pVal);
		[propput, id(2), helpstring("property NameRaw")] HRESULT NameRaw([in] BSTR newVal);
		[propget, id(3), helpstring("property Name")] HRESULT Name([out, retval] BSTR *pVal);
		[propput, id(3), helpstring("property Name")] HRESULT Name([in] BSTR newVal);
		[propget, id(4), helpstring("property RouteAddress")] HRESULT RouteAddress([out, retval] BSTR *pVal);
	};
	[
		object,
		uuid(2ED8A834-7283-4BC8-9C42-A389A917255D),
		dual,
		helpstring("ICollection Interface"),
		pointer_default(unique)
	]
	interface ICollection : IDispatch
	{
		[propget, id(DISPID_NEWENUM)] HRESULT _NewEnum( [out, retval] IUnknown** ppUnknown);
		[propget, id(DISPID_VALUE)]	  HRESULT Item([in] long Index, [out, retval] LPVARIANT pVariant);
		[propget, id(1)]			  HRESULT Count([out, retval] long* pVal);
		[id(2)]						  HRESULT Add([in] VARIANT Item);
		[id(3)]						  HRESULT Remove([in] long Index);
		[id(4)]						  HRESULT Clear();
		[id(5)]						  HRESULT Modify([in] long Index, [in] VARIANT Item);
		[propget, id(6)]			  HRESULT ItemID([in] long Index, [out] VARIANT* pID, [out, retval] LPVARIANT pVariant);
		[propget, id(7)]			  HRESULT ItemByID([in] long ID, [out, retval] LPVARIANT pVariant);
		[id(8)]						  HRESULT RemoveByID([in] long ID);
		[id(9)]						  HRESULT ModifyByID([in] long ID, [in] VARIANT Item);
	};
	[
		object,
		uuid(444D55C3-C0D6-47DC-AE6F-8C43EAF34E8E),
		dual,
		helpstring("IClientSocket Interface"),
		pointer_default(unique)
	]
	interface IClientSocket : IDispatch
	{
		[id(1), helpstring("method ConnectSMTP")] HRESULT ConnectSMTP([in] BSTR strServer, [in,defaultvalue(25)] long nPort, [out, retval] VARIANT_BOOL* pRet);
		[id(2), helpstring("method DisconnectSMTP")] HRESULT DisconnectSMTP([out, retval] VARIANT_BOOL* pRet);
		[id(3), helpstring("method PrepareSMTP")] HRESULT PrepareSMTP([in] LPDISPATCH pDecoder, [out,retval] VARIANT_BOOL* pbvarResult);
		[id(4), helpstring("method GetResultSMTP")] HRESULT GetResultSMTP([out,retval] VARIANT_BOOL* pbvarResult);
	};
	[
		object,
		uuid(827BEB32-FDED-4AA7-B5B9-955AB40267E4),
		dual,
		helpstring("IMimeBody Interface"),
		pointer_default(unique)
	]
	interface IMimeBody : IDispatch
	{
		[propget, id(DISPID_VALUE)]	  HRESULT Item([in] long Index, [out, retval] LPVARIANT pVariant);
		[propget, id(1)]			  HRESULT Count([out, retval] long* pVal);
		[id(2)]						  HRESULT AddNew([out,retval] LPDISPATCH* ppResult);
		[id(3)]						  HRESULT Remove([in] long Index);
		[id(4)]						  HRESULT Clear();
		[propget, id(20), helpstring("property MajorContentType")] HRESULT MajorContentType([out, retval] VARIANT *pVal);
		[propput, id(20), helpstring("property MajorContentType")] HRESULT MajorContentType([in] VARIANT newVal);
		[propget, id(21), helpstring("property MinorContentType")] HRESULT MinorContentType([out, retval] VARIANT *pVal);
		[propput, id(21), helpstring("property MinorContentType")] HRESULT MinorContentType([in] VARIANT newVal);
		[propget, id(22), helpstring("property ExtField")] HRESULT ExtField([in] BSTR strName, [out, retval] VARIANT *pVal);
		[propput, id(22), helpstring("property ExtField")] HRESULT ExtField([in] BSTR strName, [in] VARIANT newVal);
		[propget, id(23), helpstring("property Encoding")] HRESULT Encoding([out, retval] VARIANT *pVal);
		[propput, id(23), helpstring("property Encoding")] HRESULT Encoding([in] VARIANT newVal);
		[propget, id(24), helpstring("property Description")] HRESULT Description([out, retval] VARIANT *pVal);
		[propput, id(24), helpstring("property Description")] HRESULT Description([in] VARIANT newVal);
		[propget, id(25), helpstring("property ContentID")] HRESULT ContentID([out, retval] VARIANT *pVal);
		[propput, id(25), helpstring("property ContentID")] HRESULT ContentID([in] VARIANT newVal);
		[id(26), helpstring("method ExportAsFile")] HRESULT ExportAsFile([in] BSTR Path, [out,retval] VARIANT_BOOL* pbvarResult);
		[id(27), helpstring("method ImportFromFile")] HRESULT ImportFromFile([in] BSTR Path, [in,defaultvalue(0)] VARIANT_BOOL StreamByReference, [out,retval] VARIANT_BOOL* pbvarResult);
		[id(28), helpstring("method Export")] HRESULT Export([in] LPUNKNOWN pStream, [out,retval] VARIANT_BOOL* pbvarResult);
		[id(29), helpstring("method Import")] HRESULT Import([in] LPUNKNOWN pStream, [in,defaultvalue(0)] VARIANT_BOOL StreamByReference, [out,retval] VARIANT_BOOL* pbvarResult);
		[propget, id(30), helpstring("property FileName")] HRESULT FileName([out, retval] BSTR *pVal);
		[propput, id(30), helpstring("property FileName")] HRESULT FileName([in] BSTR newVal);
		[propget, id(31), helpstring("property Value")] HRESULT Value([out, retval] BSTR *pVal);
		[propput, id(31), helpstring("property Value")] HRESULT Value([in] BSTR newVal);
		[propget, id(32), helpstring("property EmbeddedMessage")] HRESULT EmbeddedMessage([out, retval] LPDISPATCH *pVal);
	};

	[
		uuid(DAE27546-4F73-41AE-A802-F5C4D7CD57BA),
		helpstring("MimeDecoder Class")
	]
	coclass MimeDecoder
	{
		[default] interface IMimeDecoder;
		[default, source] dispinterface _IMimeDecoderEvents;
	};
	[
		uuid(5F00447B-8A10-46AE-BDA3-F95EE73769B8),
		helpstring("MailAddress Class")
	]
	coclass MailAddress
	{
		[default] interface IMailAddress;
	};
	[
		uuid(22C47B61-CF66-43E0-8A83-E0A0422680C4),
		helpstring("Collection Class")
	]
	coclass Collection
	{
		[default] interface ICollection;
	};
	[
		uuid(1D8F02C8-4D92-4B65-8DE8-877FF4EBFA14),
		helpstring("ClientSocket Class")
	]
	coclass ClientSocket
	{
		[default] interface IClientSocket;
	};
	[
		uuid(95B35A0B-F6E6-4705-A938-321E7DE86472),
		helpstring("MimeBody Class")
	]
	coclass MimeBody
	{
		[default] interface IMimeBody;
	};
};

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions