MIME Class
Properties Methods Events Config Settings Errors
The MIME class allows for the simple encoding and decoding of MIME structures, such as message attachments and file uploads.
Syntax
MIME
Remarks
The class may be used for decoding or encoding of messages. Message holds the content of the encoded message or the filename that holds the encoded data. The decoded data are provided in Parts properties.
To decode a MIME message, you should first assign either the whole message (headers and body) to Message or put the message headers into the MessageHeaders property and the message body or the filename holding it into the Message property. Calling DecodeFromFile or DecodeFromString directs the class to start parsing the message: it will fill out the ContentType and ContentTypeAttr properties with message content-type information, and it will enter information about message parts into the Parts properties, which includes part sizes, part content types, part content type attributes, part content disposition, part content disposition attributes, part encoding, part name, part filename, part headers, or part content (part-decoded string or part-decoded file) for each decoded part.
Calling the DecodeFromString or DecodeFromFile to decode does not actually decode the message but only parses it. The real decoding is done when the part content in the Parts properties is first accessed.
To encode data into a MIME message, you should first assign values for each part to either a part-decoded string or a part- decoded file in the Parts properties property, and optionally assign values to the other part attributes in the Parts properties. Assigning a value to the part-decoded string or a part-decoded file through the Parts properties, fills out automatically the part headers into the Parts properties for the respective part. Calling EncodeToFile or EncodeToString directs the class to fill out the Message with the message body and the MessageHeaders with the headers.
The Progress event is fired as the message is parsed and the data are decoded/encoded.
Property List
The following is the full list of the properties of the class with short descriptions. Click on the links for further details.
Boundary | This property includes the boundary separating the MIME parts. It has a maximum length of 80 bytes. |
ContentType | This property includes the value of the content-type header of the message that was encoded/decoded. |
ContentTypeAttr | This property includes the attributes of the content-type header of the message that was encoded or decoded. |
Message | This property contains the encoded message text or a path to a file that contains the encoded message text. |
MessageHeaders | This property includes the headers of the MIME message. |
MessageHeadersString | This property includes the string version of the MIME message headers. |
Parts | This property contains information about all parts of a MIME message. |
Method List
The following is the full list of the methods of the class with short descriptions. Click on the links for further details.
Config | Sets or retrieves a configuration setting. |
DecodeFromFile | This method decodes from a file. |
DecodeFromStream | This method decodes from a stream. |
DecodeFromString | This method decodes from a string. |
DecodePart | This method decodes the specified part. |
DecodePartToFile | This method decodes the specified part to a file on disk. |
EncodeToFile | This method encodes to a file. |
EncodeToStream | This method encodes to a stream. |
EncodeToString | This method encodes to a string. |
Reset | This method will reset the class. |
ResetData | This method resets the values of all headers and part properties. |
Event List
The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.
Error | Fired when information is available about errors during data delivery. |
Header | This event is fired every time a header is parsed. |
Progress | This event shows the progress of decoding or encoding the input data. |
Config Settings
The following is a list of config settings for the class with short descriptions. Click on the links for further details.
DecodeMessageHeaders | Instructs the class to automatically decode message headers. |
IncludeHeaders | Tells the class whether to include the headers when encoding the message. |
RequireVersionHeader | Specifies whether or not the class should require the version header. |
SanitizeFileName | Whether invalid characters are replaced in MIME part filenames. |
TempFilePath | If set, the temporary files created during MIME decoding and encoding will be put in the path specified. |
BuildInfo | Information about the product's build. |
CodePage | The system code page used for Unicode to Multibyte translations. |
LicenseInfo | Information about the current license. |
MaskSensitiveData | Whether sensitive data is masked in log messages. |
ProcessIdleEvents | Whether the class uses its internal event loop to process events when the main thread is idle. |
SelectWaitMillis | The length of time in milliseconds the class will wait when DoEvents is called if there are no events to process. |
UseInternalSecurityAPI | Whether or not to use the system security libraries or an internal implementation. |
Boundary Property (MIME Class)
This property includes the boundary separating the MIME parts. It has a maximum length of 80 bytes.
Syntax
ANSI (Cross Platform) char* GetBoundary();
int SetBoundary(const char* lpszBoundary); Unicode (Windows) LPWSTR GetBoundary();
INT SetBoundary(LPCWSTR lpszBoundary);
char* ipworks_mime_getboundary(void* lpObj);
int ipworks_mime_setboundary(void* lpObj, const char* lpszBoundary);
QString GetBoundary();
int SetBoundary(QString qsBoundary);
Default Value
""
Remarks
This property contains the boundary separating the MIME parts and has a maximum length of 80 bytes. The class automatically generates a random boundary value during encoding, if no value is given. During decoding, this property is filled with the boundary from the actual MIME message.
The class will truncate any string longer than 80 bytes if assigned to Boundary.
Data Type
String
ContentType Property (MIME Class)
This property includes the value of the content-type header of the message that was encoded/decoded.
Syntax
ANSI (Cross Platform) char* GetContentType();
int SetContentType(const char* lpszContentType); Unicode (Windows) LPWSTR GetContentType();
INT SetContentType(LPCWSTR lpszContentType);
char* ipworks_mime_getcontenttype(void* lpObj);
int ipworks_mime_setcontenttype(void* lpObj, const char* lpszContentType);
QString GetContentType();
int SetContentType(QString qsContentType);
Default Value
""
Remarks
This property contains the value of the content-type header of the message that was encoded/decoded. The class filters it out from the MessageHeaders. It shows the user information about the type of the parts and their relation to each other.
The content-type attributes, such as filename, boundary, and charset, are held in this property.
Data Type
String
ContentTypeAttr Property (MIME Class)
This property includes the attributes of the content-type header of the message that was encoded or decoded.
Syntax
ANSI (Cross Platform) char* GetContentTypeAttr();
int SetContentTypeAttr(const char* lpszContentTypeAttr); Unicode (Windows) LPWSTR GetContentTypeAttr();
INT SetContentTypeAttr(LPCWSTR lpszContentTypeAttr);
char* ipworks_mime_getcontenttypeattr(void* lpObj);
int ipworks_mime_setcontenttypeattr(void* lpObj, const char* lpszContentTypeAttr);
QString GetContentTypeAttr();
int SetContentTypeAttr(QString qsContentTypeAttr);
Default Value
""
Remarks
This property contains content-type attributes such as "filename", "boundary", and "charset".
Data Type
String
Message Property (MIME Class)
This property contains the encoded message text or a path to a file that contains the encoded message text.
Syntax
ANSI (Cross Platform) int GetMessage(char* &lpMessage, int &lenMessage);
int SetMessage(const char* lpMessage, int lenMessage); Unicode (Windows) INT GetMessage(LPSTR &lpMessage, INT &lenMessage);
INT SetMessage(LPCSTR lpMessage, INT lenMessage);
int ipworks_mime_getmessage(void* lpObj, char** lpMessage, int* lenMessage);
int ipworks_mime_setmessage(void* lpObj, const char* lpMessage, int lenMessage);
QByteArray GetMessage();
int SetMessage(QByteArray qbaMessage);
Default Value
""
Remarks
This property contains the encoded message text or a path to a file that contains the encoded message text. The class fills out this property with the message body and MessageHeaders during encoding. The user may assign both the headers and the body to this property and leave MessageHeaders empty before decoding.
This property is not available at design time.
Data Type
Binary String
MessageHeaders Property (MIME Class)
This property includes the headers of the MIME message.
Syntax
IPWorksList<IPWorksHeader>* GetMessageHeaders(); int SetMessageHeaders(IPWorksList<IPWorksHeader>* val);
int ipworks_mime_getmessageheadercount(void* lpObj);
int ipworks_mime_setmessageheadercount(void* lpObj, int iMessageHeaderCount);
char* ipworks_mime_getmessageheaderfield(void* lpObj, int messageheaderindex);
int ipworks_mime_setmessageheaderfield(void* lpObj, int messageheaderindex, const char* lpszMessageHeaderField);
char* ipworks_mime_getmessageheadervalue(void* lpObj, int messageheaderindex);
int ipworks_mime_setmessageheadervalue(void* lpObj, int messageheaderindex, const char* lpszMessageHeaderValue);
int GetMessageHeaderCount();
int SetMessageHeaderCount(int iMessageHeaderCount); QString GetMessageHeaderField(int iMessageHeaderIndex);
int SetMessageHeaderField(int iMessageHeaderIndex, QString qsMessageHeaderField); QString GetMessageHeaderValue(int iMessageHeaderIndex);
int SetMessageHeaderValue(int iMessageHeaderIndex, QString qsMessageHeaderValue);
Remarks
This property contains the headers of the MIME message. The class fills out this property upon encoding. The user should use them as additional headers when emailing the Message.
During decoding, if this property is empty, the class will try to find the headers in the beginning of the Message and then will fill out this property accordingly.
Data Type
MessageHeadersString Property (MIME Class)
This property includes the string version of the MIME message headers.
Syntax
ANSI (Cross Platform) char* GetMessageHeadersString();
int SetMessageHeadersString(const char* lpszMessageHeadersString); Unicode (Windows) LPWSTR GetMessageHeadersString();
INT SetMessageHeadersString(LPCWSTR lpszMessageHeadersString);
char* ipworks_mime_getmessageheadersstring(void* lpObj);
int ipworks_mime_setmessageheadersstring(void* lpObj, const char* lpszMessageHeadersString);
QString GetMessageHeadersString();
int SetMessageHeadersString(QString qsMessageHeadersString);
Default Value
""
Remarks
The component fills out MessageHeadersString upon encoding. The user should use these strings as additional headers when emailing the Message.
This property contains a string version of the MIME message headers. During decoding, if this property is empty, the class will try to find the headers in the beginning of the Message and will fill out this property accordingly.
Data Type
String
Parts Property (MIME Class)
This property contains information about all parts of a MIME message.
Syntax
IPWorksList<IPWorksMIMEPart>* GetParts(); int SetParts(IPWorksList<IPWorksMIMEPart>* val);
int ipworks_mime_getpartcount(void* lpObj);
int ipworks_mime_setpartcount(void* lpObj, int iPartCount);
char* ipworks_mime_getpartcontentdisposition(void* lpObj, int partidx);
int ipworks_mime_setpartcontentdisposition(void* lpObj, int partidx, const char* lpszPartContentDisposition);
char* ipworks_mime_getpartcontentdispositionattr(void* lpObj, int partidx);
int ipworks_mime_setpartcontentdispositionattr(void* lpObj, int partidx, const char* lpszPartContentDispositionAttr);
char* ipworks_mime_getpartcontentid(void* lpObj, int partidx);
int ipworks_mime_setpartcontentid(void* lpObj, int partidx, const char* lpszPartContentId);
char* ipworks_mime_getpartcontenttype(void* lpObj, int partidx);
int ipworks_mime_setpartcontenttype(void* lpObj, int partidx, const char* lpszPartContentType);
char* ipworks_mime_getpartcontenttypeattr(void* lpObj, int partidx);
int ipworks_mime_setpartcontenttypeattr(void* lpObj, int partidx, const char* lpszPartContentTypeAttr);
int ipworks_mime_setpartdecodedfile(void* lpObj, int partidx, const char* lpszPartDecodedFile);
int ipworks_mime_getpartdecodedstring(void* lpObj, int partidx, char** lpPartDecodedString, int* lenPartDecodedString);
int ipworks_mime_setpartdecodedstring(void* lpObj, int partidx, const char* lpPartDecodedString, int lenPartDecodedString);
int ipworks_mime_getpartencoding(void* lpObj, int partidx);
int ipworks_mime_setpartencoding(void* lpObj, int partidx, int iPartEncoding);
char* ipworks_mime_getpartfilename(void* lpObj, int partidx);
int ipworks_mime_setpartfilename(void* lpObj, int partidx, const char* lpszPartFileName);
char* ipworks_mime_getpartheaders(void* lpObj, int partidx);
int ipworks_mime_setpartheaders(void* lpObj, int partidx, const char* lpszPartHeaders);
char* ipworks_mime_getpartname(void* lpObj, int partidx);
int ipworks_mime_setpartname(void* lpObj, int partidx, const char* lpszPartName);
int ipworks_mime_setpartinputstream(void* lpObj, int partidx, IPWorksStream* sPartInputStream);
int ipworks_mime_getpartsize(void* lpObj, int partidx);
int GetPartCount();
int SetPartCount(int iPartCount); QString GetPartContentDisposition(int iPartIdx);
int SetPartContentDisposition(int iPartIdx, QString qsPartContentDisposition); QString GetPartContentDispositionAttr(int iPartIdx);
int SetPartContentDispositionAttr(int iPartIdx, QString qsPartContentDispositionAttr); QString GetPartContentId(int iPartIdx);
int SetPartContentId(int iPartIdx, QString qsPartContentId); QString GetPartContentType(int iPartIdx);
int SetPartContentType(int iPartIdx, QString qsPartContentType); QString GetPartContentTypeAttr(int iPartIdx);
int SetPartContentTypeAttr(int iPartIdx, QString qsPartContentTypeAttr); int SetPartDecodedFile(int iPartIdx, QString qsPartDecodedFile); QByteArray GetPartDecodedString(int iPartIdx);
int SetPartDecodedString(int iPartIdx, QByteArray qbaPartDecodedString); int GetPartEncoding(int iPartIdx);
int SetPartEncoding(int iPartIdx, int iPartEncoding); QString GetPartFileName(int iPartIdx);
int SetPartFileName(int iPartIdx, QString qsPartFileName); QString GetPartHeaders(int iPartIdx);
int SetPartHeaders(int iPartIdx, QString qsPartHeaders); QString GetPartName(int iPartIdx);
int SetPartName(int iPartIdx, QString qsPartName); int SetPartInputStream(int iPartIdx, IPWorksStream* sPartInputStream); int GetPartSize(int iPartIdx);
Remarks
This property contains information about all parts of a MIME message. A MIME message consists of different parts, separated by either a user-specified or an auto-generated boundary. Each part has its own set of headers that are contained in the Headers field.
The MIMEPARTS collection is filled out by the class when a call to either DecodeFromFile or DecodeFromString is made. However, when the EncodeToFile or EncodeToString methods are called, the class encodes the data given in either DecodedFile or DecodedString into a MIME message.
Data Type
Config Method (MIME Class)
Sets or retrieves a configuration setting.
Syntax
ANSI (Cross Platform) char* Config(const char* lpszConfigurationString); Unicode (Windows) LPWSTR Config(LPCWSTR lpszConfigurationString);
char* ipworks_mime_config(void* lpObj, const char* lpszConfigurationString);
QString Config(const QString& qsConfigurationString);
Remarks
Config is a generic method available in every class. It is used to set and retrieve configuration settings for the class.
These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.
To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).
To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.
Error Handling (C++)
This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.
DecodeFromFile Method (MIME Class)
This method decodes from a file.
Syntax
ANSI (Cross Platform) int DecodeFromFile(); Unicode (Windows) INT DecodeFromFile();
int ipworks_mime_decodefromfile(void* lpObj);
int DecodeFromFile();
Remarks
This method decodes the data file given in Message and optionally MessageHeaders and fills out the Parts properties for each decoded part.
Example. Decoding from a File:
MIMEControl.Message = "C:\filename.txt"
MIMEControl.DecodeFromFile
In this example, C:\filename.txt must contain the MIME headers and body. If not, the MessageHeaders property must be set to the appropriate MIME headers.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
DecodeFromStream Method (MIME Class)
This method decodes from a stream.
Syntax
ANSI (Cross Platform) int DecodeFromStream(IPWorksStream* sInputStream); Unicode (Windows) INT DecodeFromStream(IPWorksStream* sInputStream);
int ipworks_mime_decodefromstream(void* lpObj, IPWorksStream* sInputStream);
int DecodeFromStream(IPWorksStream* sInputStream);
Remarks
This method decodes from a stream. It is the same as DecodeFromString, but now the MIME message is passed to this method as a stream.
This method decodes the data given by the InputStream and optionally MessageHeaders and fills out the Parts properties.
Example. Decoding a Mail Message:
MIMEControl.MessageHeaders.AddRange(MailControl.MessageHeaders)
MIMEControl.DecodeFromStream(InputStream)
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
DecodeFromString Method (MIME Class)
This method decodes from a string.
Syntax
ANSI (Cross Platform) int DecodeFromString(); Unicode (Windows) INT DecodeFromString();
int ipworks_mime_decodefromstring(void* lpObj);
int DecodeFromString();
Remarks
This method decodes from a string. It is the same as DecodeFromFile, but now the Message denotes the real encoded message rather than a filename.
This method decodes the data given in Message and optionally MessageHeaders and fills out the Parts properties.
Example. Decoding a Mail Message:
MIMEControl.MessageHeadersString = MailControl.MessageHeaders
MIMEControl.Message = MailControl.MessageText
MIMEControl.DecodeFromString
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
DecodePart Method (MIME Class)
This method decodes the specified part.
Syntax
ANSI (Cross Platform) char* DecodePart(int iindex, int *lpSize = NULL); Unicode (Windows) LPSTR DecodePart(INT iindex, LPINT lpSize = NULL);
char* ipworks_mime_decodepart(void* lpObj, int iindex, int *lpSize);
QByteArray DecodePart(int iindex);
Remarks
This method decodes the part specified by Index and returns the decoded part data.
DecodeFromString or DecodeFromFile must be called before calling this method. Calling this method will return the decoded bytes, and in addition, the DecodedString field will be populated with the string representation of the decoded data.
Example. Decoding a Specified Part:
mime.MessageHeadersString = myMessageHeaders;
mime.Message = myMessageBody;
mime.DecodeFromString();
byte[] myPartContent = await mime.DecodePart(0);
Error Handling (C++)
This method returns a Binary String value (with length lpSize); after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.
DecodePartToFile Method (MIME Class)
This method decodes the specified part to a file on disk.
Syntax
ANSI (Cross Platform) char* DecodePartToFile(int iindex); Unicode (Windows) LPWSTR DecodePartToFile(INT iindex);
char* ipworks_mime_decodeparttofile(void* lpObj, int iindex);
QString DecodePartToFile(int iindex);
Remarks
This method decodes the part specified by Index to a temporary file. The full path to the temporary file is returned by this method. The user is responsible for deleting the temporary file.
DecodeFromString or DecodeFromFile must be called before calling this method.
Error Handling (C++)
This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.
EncodeToFile Method (MIME Class)
This method encodes to a file.
Syntax
ANSI (Cross Platform) int EncodeToFile(); Unicode (Windows) INT EncodeToFile();
int ipworks_mime_encodetofile(void* lpObj);
int EncodeToFile();
Remarks
This method encodes the data given in Parts properties (either a decoded file or a decoded string) into a MIME message at Message and MessageHeaders using the values optionally given in Parts properties. To encode several objects into a MIME envelope, the user should first clear any old values left in the Parts properties.
The class will check for each item in Parts properties (first the decoded file and then the decoded string) for the data to encode.
The encoded message will be saved in the file pointed to by Message; the message headers will be held by MessageHeaders.
Example. Encoding Data:
MIMEControl.ResetData()
MIMEControl.PartCount = 2
MIMEControl.PartDecodedString(0) = "This is plain text data"
MIMEControl.PartEncoding(0) = peQuotedPrintable
MIMEControl.PartContentType(0) = "text/plain"
MIMEControl.PartDecodedFile(1) = "C:\filename.txt"
MIMEControl.Message = "temp.tmp"
MIMEControl.EncodeToFile()
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
EncodeToStream Method (MIME Class)
This method encodes to a stream.
Syntax
ANSI (Cross Platform) int EncodeToStream(IPWorksStream* sOutputStream); Unicode (Windows) INT EncodeToStream(IPWorksStream* sOutputStream);
int ipworks_mime_encodetostream(void* lpObj, IPWorksStream* sOutputStream);
int EncodeToStream(IPWorksStream* sOutputStream);
Remarks
This method encodes to a stream. It is the same as EncodeToString, but the encoded data are written to a stream instead of to the Message property.
This method encodes the data given in Parts collection into a MIME message. The Message gets written to the specified OutputStream and MessageHeaders using the values optionally given in the Parts collection. To encode several objects into a MIME envelope, the user should first clear any old values left in the Parts collection by calling ResetData.
The class will check each item in the Parts collection (first the decoded file and then the decoded string) for the data to encode.
The encoded message will be written to the specified OutputStream, and the message headers will be held by MessageHeaders.
Example. Encoding Data:
MIMEControl.ResetData()
MIMEControl.Parts.Add(new MIMEPart())
MIMEControl.Parts.Add(new MIMEPart())
MIMEControl.Parts[0].DecodedString = "This is plain text data"
MIMEControl.Parts[0].Encoding = peQuotedPrintable
MIMEControl.Parts[0].ContentType = "text/plain"
MIMEControl.Parts[1].DecodedFile = "C:\filename.txt"
MIMEControl.EncodeToStream(OutputStream)
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
EncodeToString Method (MIME Class)
This method encodes to a string.
Syntax
ANSI (Cross Platform) int EncodeToString(); Unicode (Windows) INT EncodeToString();
int ipworks_mime_encodetostring(void* lpObj);
int EncodeToString();
Remarks
This method encodes to a string. It is the same as EncodeToFile but the encoded data are held in the Message property rather than saved to a file.
This method encodes the data given in the Parts properties into a MIME message. The message gets stored in Message and MessageHeaders using the values optionally given in Parts properties. To encode several objects into a MIME envelope, the user should first clear any old values left in the Parts properties by calling ResetData.
The class will check each item in the Parts properties (first the decoded file and then the decoded string) for the data to encode.
The encoded message will be stored in the Message property; the message headers will be held by MessageHeaders.
Example. Encoding Data:
MIMEControl.ResetData()
MIMEControl.PartCount = 2
MIMEControl.PartDecodedString(0) = "This is plain text data"
MIMEControl.PartEncoding(0) = peQuotedPrintable
MIMEControl.PartContentType(0) = "text/plain"
MIMEControl.PartDecodedFile(1) = "C:\filename.txt"
MIMEControl.EncodeToString()
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
Reset Method (MIME Class)
This method will reset the class.
Syntax
ANSI (Cross Platform) int Reset(); Unicode (Windows) INT Reset();
int ipworks_mime_reset(void* lpObj);
int Reset();
Remarks
This method will reset the class's properties to their default values.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
ResetData Method (MIME Class)
This method resets the values of all headers and part properties.
Syntax
ANSI (Cross Platform) int ResetData(); Unicode (Windows) INT ResetData();
int ipworks_mime_resetdata(void* lpObj);
int ResetData();
Remarks
This method resets the values of all headers and part properties. It is an easy way to reset the class's properties before starting to populate the part properties with new values.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
Error Event (MIME Class)
Fired when information is available about errors during data delivery.
Syntax
ANSI (Cross Platform) virtual int FireError(MIMEErrorEventParams *e);
typedef struct {
int ErrorCode;
const char *Description; int reserved; } MIMEErrorEventParams;
Unicode (Windows) virtual INT FireError(MIMEErrorEventParams *e);
typedef struct {
INT ErrorCode;
LPCWSTR Description; INT reserved; } MIMEErrorEventParams;
#define EID_MIME_ERROR 1 virtual INT IPWORKS_CALL FireError(INT &iErrorCode, LPSTR &lpszDescription);
class MIMEErrorEventParams { public: int ErrorCode(); const QString &Description(); int EventRetVal(); void SetEventRetVal(int iRetVal); };
// To handle, connect one or more slots to this signal. void Error(MIMEErrorEventParams *e);
// Or, subclass MIME and override this emitter function. virtual int FireError(MIMEErrorEventParams *e) {...}
Remarks
The Error event is fired in case of exceptional conditions during message processing. Normally the class fails with an error.
The ErrorCode parameter contains an error code, and the Description parameter contains a textual description of the error. For a list of valid error codes and their descriptions, please refer to the Error Codes section.
Header Event (MIME Class)
This event is fired every time a header is parsed.
Syntax
ANSI (Cross Platform) virtual int FireHeader(MIMEHeaderEventParams *e);
typedef struct {
int PartIndex;
const char *Field;
const char *Value; int lenValue; int reserved; } MIMEHeaderEventParams;
Unicode (Windows) virtual INT FireHeader(MIMEHeaderEventParams *e);
typedef struct {
INT PartIndex;
LPCWSTR Field;
LPCSTR Value; INT lenValue; INT reserved; } MIMEHeaderEventParams;
#define EID_MIME_HEADER 2 virtual INT IPWORKS_CALL FireHeader(INT &iPartIndex, LPSTR &lpszField, LPSTR &lpValue, INT &lenValue);
class MIMEHeaderEventParams { public: int PartIndex(); const QString &Field(); const QByteArray &Value(); int EventRetVal(); void SetEventRetVal(int iRetVal); };
// To handle, connect one or more slots to this signal. void Header(MIMEHeaderEventParams *e);
// Or, subclass MIME and override this emitter function. virtual int FireHeader(MIMEHeaderEventParams *e) {...}
Remarks
The PartIndex parameter contains the index of the part containing the current header. If the header is from the MIME body, this value will be -1. The Field parameter contains the name of the MIME header. The Value parameter contains the header contents. The Header event is fired when a header is parsed, which occurs for each header of the message when DecodeFromFile, DecodeFromString, or DecodeFromStream is called.
Progress Event (MIME Class)
This event shows the progress of decoding or encoding the input data.
Syntax
ANSI (Cross Platform) virtual int FireProgress(MIMEProgressEventParams *e);
typedef struct {
int PercentDone; int reserved; } MIMEProgressEventParams;
Unicode (Windows) virtual INT FireProgress(MIMEProgressEventParams *e);
typedef struct {
INT PercentDone; INT reserved; } MIMEProgressEventParams;
#define EID_MIME_PROGRESS 3 virtual INT IPWORKS_CALL FireProgress(INT &iPercentDone);
class MIMEProgressEventParams { public: int PercentDone(); int EventRetVal(); void SetEventRetVal(int iRetVal); };
// To handle, connect one or more slots to this signal. void Progress(MIMEProgressEventParams *e);
// Or, subclass MIME and override this emitter function. virtual int FireProgress(MIMEProgressEventParams *e) {...}
Remarks
The Progress allows the user to visualize the progress of processing the input data.
The PercentDone parameter shows what percentage of the input has been read.
Header Type
This is an HTTP header as it is received from the server.
Syntax
IPWorksHeader (declared in ipworks.h)
Remarks
When a header is received through a Header event, it is parsed into a Header type. This type contains a Field, and its corresponding Value.
Fields
Field
char*
Default Value: ""
This field contains the name of the HTTP Header (this is the same case as it is delivered).
Value
char*
Default Value: ""
This field contains the Header contents.
Constructors
Header()
Header(const char* lpszField, const char* lpszValue)
MIMEPart Type
This is a part of the MIME message.
Syntax
IPWorksMIMEPart (declared in ipworks.h)
Remarks
Each MIME message is split into parts. A message must have at least one part to be a valid MIME message. The message itself is split into the MessageHeaders and the Message body. The body is then split into MIME parts by a specified or generated Boundary. Each part of a MIME message has its own Headers as well. These headers describe the MIMEPart and its contents.
The decoded data will be held in DecodedString or otherwise will be saved in a temporary file given by DecodedFile when the user asks for the value of the respective field.
If the encoded data are file data, the decoded file(s) will be given in the DecodedFile field. Otherwise, the decoded data will be in the DecodedString field.
When the EncodeToString method is called, the class will check for each item in the Parts properties (first the DecodedFile and then the DecodedString) for the data to encode.
Fields
ContentDisposition
char*
Default Value: ""
This field contains content disposition for each part.
The value in this field is used in the Content-Disposition header. Typical values include "form-data" and "attachment". The class fills it out each time the DecodedFile is changed. Changing the ContentDisposition recalculates the Headers as well.
ContentDispositionAttr
char*
Default Value: ""
This field contains the content disposition's attribute (if any) for each part.
Typical values for this field are the names of the form-variables used while creating an HTTP post or the values for filenames.
Setting this field recalculates the Headers.
ContentId
char*
Default Value: ""
This field contains the content identifier for each part. The value of this field is used in the Content-Id header. The class fills it out each time the DecodedFile is changed. Changing this field recalculates the Headers as well.
ContentType
char*
Default Value: ""
This field contains the content type for each part. The value of this field is used in the Content-Type header. Typical values include "image/gif" and "text/plain". The class fills it out each time the DecodedFile is changed. Changing this field recalculates the Headers as well.
ContentTypeAttr
char*
Default Value: ""
This field contains the content-type attribute, if any, for each part. Setting this recalculates the Headers as well.
DecodedFile
char*
Default Value: ""
This field may be set to a file on disk before calling EncodeToString, EncodeToFile or EncodeToStream. When encoding, data for the part will be read from the specified file.
When decoding, call DecodePartToFile to decode a specific part to a file on disk.
DecodedString
char*
Default Value: ""
This field holds the actual content of each part. The class decodes the actual part of Message to DecodedString when DecodedString's value is first queried.
Setting a value to DecodedString fills out the corresponding Size with the string size if the corresponding DecodedFile is empty.
The class checks during encoding first DecodedFile: if it is empty, then the class uses the value of DecodedString.
Note: It is recommended to use the DecodePart method instead of querying this property.
Encoding
int
Default Value: 0
This field contains the actual content encoding type for each part. This field determines how to encode the data or how they actually were encoded in the Message, as specified in the Content-Transfer-Encoding header.
Possible values for the this field are as follows:
pe7bit (0) | 7 Bit data, no encoding. |
peQuotedPrintable (1) | Quoted-Printable encoding of (typically) text. |
peBase64 (2) | Base64 encoding of binary data. |
pe8Bit (3) | No encoding, 8-bit characters may be contained as well. |
peBinary (4) | Binary data without any encoding. Similar to 3 (8-bit encoding). |
peUUEncode (5) | Uuencoding of binary data. |
FileName
char*
Default Value: ""
This field contains the filename attribute specified in the headers of the part. Changing the value of the corresponding DecodedFile automatically sets the FileName and consequently the Headers.
Headers
char*
Default Value: ""
This field contains the headers for each MIME part. The class fills out this field each time any of the other corresponding part properties are changed. If additional headers are needed, they should be appended after all of the other corresponding part properties are set.
Name
char*
Default Value: ""
This field contains the name given to a part, such as the filename. Changing the value of DecodedFile automatically sets the corresponding Name and consequently the Headers.
Size
int (read-only)
Default Value: 0
This field contains the size of the DecodedFile or DecodedString. If a non-empty value is assigned to DecodedFile, then class fills out the corresponding Size with the file size; if the file does not exist, an error occurs.
If the DecodedFile is empty and a value is assigned to DecodedString, then the corresponding Size will be equal to the string's size.
During decoding, this field is filled with the size of that part.
Constructors
MIMEPart()
MIMEPart(const char* lpszDecodedFile)
MIMEPart(const char* lpDecodedString, int lenDecodedString)
MIMEPart(IPWorksStream* sPartInputStream)
IPWorksList Type
Syntax
IPWorksList<T> (declared in ipworks.h)
Remarks
IPWorksList is a generic class that is used to hold a collection of objects of type T, where T is one of the custom types supported by the MIME class.
Methods | |
GetCount |
This method returns the current size of the collection.
int GetCount() {}
|
SetCount |
This method sets the size of the collection. This method returns 0 if setting the size was successful; or -1 if the collection is ReadOnly. When adding additional objects to a collection call this method to specify the new size. Increasing the size of the collection preserves existing objects in the collection.
int SetCount(int count) {}
|
Get |
This method gets the item at the specified position. The index parameter specifies the index of the item in the collection. This method returns NULL if an invalid index is specified.
T* Get(int index) {}
|
Set |
This method sets the item at the specified position. The index parameter specifies the index of the item in the collection that is being set. This method returns -1 if an invalid index is specified. Note: Objects created using the new operator must be freed using the delete operator; they will not be automatically freed by the class.
T* Set(int index, T* value) {}
|
IPWorksStream Type
Syntax
IPWorksStream (declared in ipworks.h)
Remarks
The MIME class includes one or more API members that take a stream object as a parameter. To use such API members, create a concrete class that implements the IPWorksStream interface and pass the MIME class an instance of that concrete class.
When implementing the IPWorksStream interface's properties and methods, they must behave as described below. If the concrete class's implementation does not behave as expected, undefined behavior may occur.
Properties | |
CanRead |
Whether the stream supports reading.
bool CanRead() { return true; } |
CanSeek |
Whether the stream supports seeking.
bool CanSeek() { return true; } |
CanWrite |
Whether the stream supports writing.
bool CanWrite() { return true; } |
Length |
Gets the length of the stream, in bytes.
int64 GetLength() = 0; |
Methods | |
Close |
Closes the stream, releasing all resources currently allocated for it.
void Close() {} This method is called automatically when an IPWorksStream object is deleted. |
Flush |
Forces all data held by the stream's buffers to be written out to storage.
int Flush() { return 0; } Must return 0 if flushing is successful; or -1 if an error occurs or the stream is closed. If the stream does not support writing, this method must do nothing and return 0. |
Read |
Reads a sequence of bytes from the stream and advances the current position within the stream by the number of bytes read.
int Read(void* buffer, int count) = 0; Buffer specifies the buffer to populate with data from the stream. Count specifies the number of bytes that should be read from the stream. Must return the total number of bytes read into Buffer; this may be less than Count if that many bytes are not currently available, or 0 if the end of the stream has been reached. Must return -1 if an error occurs, if reading is not supported, or if the stream is closed. |
Seek |
Sets the current position within the stream based on a particular point of origin.
int64 Seek(int64 offset, int seekOrigin) = 0; Offset specifies the offset in the stream to seek to, relative to SeekOrigin. Valid values for SeekOrigin are:
Must return the new position within the stream; or -1 if an error occurs, if seeking is not supported, or if the stream is closed (however, see note below). If -1 is returned, the current position within the stream must remain unchanged. Note: If the stream is not closed, it must always be possible to call this method with an Offset of 0 and a SeekOrigin of 1 to obtain the current position within the stream, even if seeking is not otherwise supported. |
Write |
Writes a sequence of bytes to the stream and advances the current position within the stream by the number of bytes written.
int Write(const void* buffer, int count) = 0; Buffer specifies the buffer with data to write to the stream. Count specifies the number of bytes that should be written to the stream. Must return the total number of bytes written to the stream; this may be less than Count if that many bytes could not be written. Must return -1 if an error occurs, if writing is not supported, or if the stream is closed. |
Config Settings (MIME Class)
The class accepts one or more of the following configuration settings. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.MIME Config Settings
The default value for IncludeHeaders is False.
- \
- /
- "
- :
- ?
- *
- <
- >
- |
Base Config Settings
The following is a list of valid code page identifiers:
Identifier | Name |
037 | IBM EBCDIC - U.S./Canada |
437 | OEM - United States |
500 | IBM EBCDIC - International |
708 | Arabic - ASMO 708 |
709 | Arabic - ASMO 449+, BCON V4 |
710 | Arabic - Transparent Arabic |
720 | Arabic - Transparent ASMO |
737 | OEM - Greek (formerly 437G) |
775 | OEM - Baltic |
850 | OEM - Multilingual Latin I |
852 | OEM - Latin II |
855 | OEM - Cyrillic (primarily Russian) |
857 | OEM - Turkish |
858 | OEM - Multilingual Latin I + Euro symbol |
860 | OEM - Portuguese |
861 | OEM - Icelandic |
862 | OEM - Hebrew |
863 | OEM - Canadian-French |
864 | OEM - Arabic |
865 | OEM - Nordic |
866 | OEM - Russian |
869 | OEM - Modern Greek |
870 | IBM EBCDIC - Multilingual/ROECE (Latin-2) |
874 | ANSI/OEM - Thai (same as 28605, ISO 8859-15) |
875 | IBM EBCDIC - Modern Greek |
932 | ANSI/OEM - Japanese, Shift-JIS |
936 | ANSI/OEM - Simplified Chinese (PRC, Singapore) |
949 | ANSI/OEM - Korean (Unified Hangul Code) |
950 | ANSI/OEM - Traditional Chinese (Taiwan; Hong Kong SAR, PRC) |
1026 | IBM EBCDIC - Turkish (Latin-5) |
1047 | IBM EBCDIC - Latin 1/Open System |
1140 | IBM EBCDIC - U.S./Canada (037 + Euro symbol) |
1141 | IBM EBCDIC - Germany (20273 + Euro symbol) |
1142 | IBM EBCDIC - Denmark/Norway (20277 + Euro symbol) |
1143 | IBM EBCDIC - Finland/Sweden (20278 + Euro symbol) |
1144 | IBM EBCDIC - Italy (20280 + Euro symbol) |
1145 | IBM EBCDIC - Latin America/Spain (20284 + Euro symbol) |
1146 | IBM EBCDIC - United Kingdom (20285 + Euro symbol) |
1147 | IBM EBCDIC - France (20297 + Euro symbol) |
1148 | IBM EBCDIC - International (500 + Euro symbol) |
1149 | IBM EBCDIC - Icelandic (20871 + Euro symbol) |
1200 | Unicode UCS-2 Little-Endian (BMP of ISO 10646) |
1201 | Unicode UCS-2 Big-Endian |
1250 | ANSI - Central European |
1251 | ANSI - Cyrillic |
1252 | ANSI - Latin I |
1253 | ANSI - Greek |
1254 | ANSI - Turkish |
1255 | ANSI - Hebrew |
1256 | ANSI - Arabic |
1257 | ANSI - Baltic |
1258 | ANSI/OEM - Vietnamese |
1361 | Korean (Johab) |
10000 | MAC - Roman |
10001 | MAC - Japanese |
10002 | MAC - Traditional Chinese (Big5) |
10003 | MAC - Korean |
10004 | MAC - Arabic |
10005 | MAC - Hebrew |
10006 | MAC - Greek I |
10007 | MAC - Cyrillic |
10008 | MAC - Simplified Chinese (GB 2312) |
10010 | MAC - Romania |
10017 | MAC - Ukraine |
10021 | MAC - Thai |
10029 | MAC - Latin II |
10079 | MAC - Icelandic |
10081 | MAC - Turkish |
10082 | MAC - Croatia |
12000 | Unicode UCS-4 Little-Endian |
12001 | Unicode UCS-4 Big-Endian |
20000 | CNS - Taiwan |
20001 | TCA - Taiwan |
20002 | Eten - Taiwan |
20003 | IBM5550 - Taiwan |
20004 | TeleText - Taiwan |
20005 | Wang - Taiwan |
20105 | IA5 IRV International Alphabet No. 5 (7-bit) |
20106 | IA5 German (7-bit) |
20107 | IA5 Swedish (7-bit) |
20108 | IA5 Norwegian (7-bit) |
20127 | US-ASCII (7-bit) |
20261 | T.61 |
20269 | ISO 6937 Non-Spacing Accent |
20273 | IBM EBCDIC - Germany |
20277 | IBM EBCDIC - Denmark/Norway |
20278 | IBM EBCDIC - Finland/Sweden |
20280 | IBM EBCDIC - Italy |
20284 | IBM EBCDIC - Latin America/Spain |
20285 | IBM EBCDIC - United Kingdom |
20290 | IBM EBCDIC - Japanese Katakana Extended |
20297 | IBM EBCDIC - France |
20420 | IBM EBCDIC - Arabic |
20423 | IBM EBCDIC - Greek |
20424 | IBM EBCDIC - Hebrew |
20833 | IBM EBCDIC - Korean Extended |
20838 | IBM EBCDIC - Thai |
20866 | Russian - KOI8-R |
20871 | IBM EBCDIC - Icelandic |
20880 | IBM EBCDIC - Cyrillic (Russian) |
20905 | IBM EBCDIC - Turkish |
20924 | IBM EBCDIC - Latin-1/Open System (1047 + Euro symbol) |
20932 | JIS X 0208-1990 & 0121-1990 |
20936 | Simplified Chinese (GB2312) |
21025 | IBM EBCDIC - Cyrillic (Serbian, Bulgarian) |
21027 | Extended Alpha Lowercase |
21866 | Ukrainian (KOI8-U) |
28591 | ISO 8859-1 Latin I |
28592 | ISO 8859-2 Central Europe |
28593 | ISO 8859-3 Latin 3 |
28594 | ISO 8859-4 Baltic |
28595 | ISO 8859-5 Cyrillic |
28596 | ISO 8859-6 Arabic |
28597 | ISO 8859-7 Greek |
28598 | ISO 8859-8 Hebrew |
28599 | ISO 8859-9 Latin 5 |
28605 | ISO 8859-15 Latin 9 |
29001 | Europa 3 |
38598 | ISO 8859-8 Hebrew |
50220 | ISO 2022 Japanese with no halfwidth Katakana |
50221 | ISO 2022 Japanese with halfwidth Katakana |
50222 | ISO 2022 Japanese JIS X 0201-1989 |
50225 | ISO 2022 Korean |
50227 | ISO 2022 Simplified Chinese |
50229 | ISO 2022 Traditional Chinese |
50930 | Japanese (Katakana) Extended |
50931 | US/Canada and Japanese |
50933 | Korean Extended and Korean |
50935 | Simplified Chinese Extended and Simplified Chinese |
50936 | Simplified Chinese |
50937 | US/Canada and Traditional Chinese |
50939 | Japanese (Latin) Extended and Japanese |
51932 | EUC - Japanese |
51936 | EUC - Simplified Chinese |
51949 | EUC - Korean |
51950 | EUC - Traditional Chinese |
52936 | HZ-GB2312 Simplified Chinese |
54936 | Windows XP: GB18030 Simplified Chinese (4 Byte) |
57002 | ISCII Devanagari |
57003 | ISCII Bengali |
57004 | ISCII Tamil |
57005 | ISCII Telugu |
57006 | ISCII Assamese |
57007 | ISCII Oriya |
57008 | ISCII Kannada |
57009 | ISCII Malayalam |
57010 | ISCII Gujarati |
57011 | ISCII Punjabi |
65000 | Unicode UTF-7 |
65001 | Unicode UTF-8 |
Identifier | Name |
1 | ASCII |
2 | NEXTSTEP |
3 | JapaneseEUC |
4 | UTF8 |
5 | ISOLatin1 |
6 | Symbol |
7 | NonLossyASCII |
8 | ShiftJIS |
9 | ISOLatin2 |
10 | Unicode |
11 | WindowsCP1251 |
12 | WindowsCP1252 |
13 | WindowsCP1253 |
14 | WindowsCP1254 |
15 | WindowsCP1250 |
21 | ISO2022JP |
30 | MacOSRoman |
10 | UTF16String |
0x90000100 | UTF16BigEndian |
0x94000100 | UTF16LittleEndian |
0x8c000100 | UTF32String |
0x98000100 | UTF32BigEndian |
0x9c000100 | UTF32LittleEndian |
65536 | Proprietary |
- Product: The product the license is for.
- Product Key: The key the license was generated from.
- License Source: Where the license was found (e.g., RuntimeLicense, License File).
- License Type: The type of license installed (e.g., Royalty Free, Single Server).
- Last Valid Build: The last valid build number for which the license will work.
This setting only works on these classes: AS3Receiver, AS3Sender, Atom, Client(3DS), FTP, FTPServer, IMAP, OFTPClient, SSHClient, SCP, Server(3DS), Sexec, SFTP, SFTPServer, SSHServer, TCPClient, TCPServer.
Setting this configuration setting to true tells the class to use the internal implementation instead of using the system security libraries.
On Windows, this setting is set to false by default. On Linux/macOS, this setting is set to true by default.
To use the system security libraries for Linux, OpenSSL support must be enabled. For more information on how to enable OpenSSL, please refer to the OpenSSL Notes section.
Trappable Errors (MIME Class)
Error Handling (C++)
Call the GetLastErrorCode() method to obtain the last called method's result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. Known error codes are listed below. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.
MIME Errors
3 | Can't create the file for write (illegal name or disk is write-protected). |
4 | Can't open the file for read (doesn't exist?). |
5 | Can't read from file. |
6 | Can't write to file (disk full?). |
280 | Invalid Part Index. |
281 | Unknown MIME type. |
282 | No MIME-boundary found. |
283 | No file given. |
284 | The class is busy. |
285 | Can't create a temporary file to decode the data. |
286 | Can't read Message file. |
287 | No header separator found. |
289 | No separator found. |
290 | Input stream must have seeking enabled. |