Struct ipworkssmime::MIME
Properties Methods Events Config Settings Errors
The MIME struct allows for the simple encoding and decoding of MIME structures, such as message attachments and file uploads.
Syntax
ipworkssmime::MIME
Remarks
The struct 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 message_headers property and the message body or the filename holding it into the message property. Calling decode_from_file or decode_from_string directs the struct to start parsing the message: it will fill out the content_type and content_type_attr 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 decode_from_string or decode_from_file 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 encode_to_file or encode_to_string directs the struct to fill out the message with the message body and the message_headers with the headers.
The on_progress event is fired as the message is parsed and the data are decoded/encoded.
Object Lifetime
The new() method returns a mutable reference to a struct instance. The object itself is kept in the global list maintained by IPWorksSMIME. Due to this, the MIME struct cannot be disposed of automatically. Please, call the dispose(&mut self) method of MIME when you have finished using the instance.
Property List
The following is the full list of the properties of the struct 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. |
| content_type | This property includes the value of the content-type header of the message that was encoded/decoded. |
| content_type_attr | 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. |
| message_header_count | The number of records in the MessageHeader arrays. |
| message_header_field | This property contains the name of the HTTP header (this is the same case as it is delivered). |
| message_header_value | This property contains the header contents. |
| message_headers_string | This property includes the string version of the MIME message headers. |
| part_count | The number of records in the Part arrays. |
| part_content_disposition | This property contains content disposition for each part. |
| part_content_disposition_attr | This property contains the content disposition's attribute (if any) for each part. |
| part_content_id | This property contains the content identifier for each part. |
| part_content_type | This property contains the content type for each part. |
| part_content_type_attr | This property contains the content-type attribute, if any, for each part. |
| part_decoded_file | This property may be set to a file on disk before calling EncodeToString , EncodeToFile or EncodeToStream . |
| part_decoded_string | This property holds the actual content of each part. |
| part_encoding | This property contains the actual content encoding type for each part. |
| part_file_name | This property contains the filename attribute specified in the headers of the part. |
| part_headers | This property contains the headers for each MIME part. |
| part_name | This property contains the name given to a part, such as the filename. |
| part_size | This property contains the size of the DecodedFile or DecodedString . |
Method List
The following is the full list of the methods of the struct with short descriptions. Click on the links for further details.
| config | Sets or retrieves a configuration setting. |
| decode_from_file | This method decodes from a file. |
| decode_from_string | This method decodes from a string. |
| decode_part | This method decodes the specified part. |
| decode_part_to_file | This method decodes the specified part to a file on disk. |
| encode_to_file | This method encodes to a file. |
| encode_to_string | This method encodes to a string. |
| reset | This method will reset the struct. |
| reset_data | 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 struct with short descriptions. Click on the links for further details.
| on_error | Fired when information is available about errors during data delivery. |
| on_header | This event is fired every time a header is parsed. |
| on_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 struct with short descriptions. Click on the links for further details.
| DecodeMessageHeaders | Instructs the struct to automatically decode message headers. |
| IncludeHeaders | Tells the struct whether to include the headers when encoding the message. |
| RequireVersionHeader | Specifies whether or not the struct 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. |
| UseInternalSecurityAPI | Whether or not to use the system security libraries or an internal implementation. |
boundary property (MIME Struct)
This property includes the boundary separating the MIME parts. It has a maximum length of 80 bytes.
Syntax
fn boundary(&self ) -> Result<String, IPWorksSMIMEError>
fn set_boundary(&self, value : &str) -> Option<IPWorksSMIMEError> fn set_boundary_ref(&self, value : &String) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
This property contains the boundary separating the MIME parts and has a maximum length of 80 bytes. The struct 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 struct will truncate any string longer than 80 bytes if assigned to boundary.
Data Type
String
content_type property (MIME Struct)
This property includes the value of the content-type header of the message that was encoded/decoded.
Syntax
fn content_type(&self ) -> Result<String, IPWorksSMIMEError>
fn set_content_type(&self, value : &str) -> Option<IPWorksSMIMEError> fn set_content_type_ref(&self, value : &String) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
This property contains the value of the content-type header of the message that was encoded/decoded. The struct filters it out from the message_headers. 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
content_type_attr property (MIME Struct)
This property includes the attributes of the content-type header of the message that was encoded or decoded.
Syntax
fn content_type_attr(&self ) -> Result<String, IPWorksSMIMEError>
fn set_content_type_attr(&self, value : &str) -> Option<IPWorksSMIMEError> fn set_content_type_attr_ref(&self, value : &String) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
This property contains content-type attributes such as "filename", "boundary", and "charset".
Data Type
String
message property (MIME Struct)
This property contains the encoded message text or a path to a file that contains the encoded message text.
Syntax
fn message(&self ) -> Result<Vec<u8>, IPWorksSMIMEError>
fn set_message(&self, value : Vec<u8>) -> Option<IPWorksSMIMEError> fn set_message_ref(&self, value : &[u8]) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
This property contains the encoded message text or a path to a file that contains the encoded message text. The struct fills out this property with the message body and message_headers during encoding. The user may assign both the headers and the body to this property and leave message_headers empty before decoding.
Data Type
Vec
message_header_count property (MIME Struct)
The number of records in the MessageHeader arrays.
Syntax
fn message_header_count(&self ) -> Result<i32, IPWorksSMIMEError>
fn set_message_header_count(&self, value : i32) -> Option<IPWorksSMIMEError>
Default Value
0
Remarks
This property controls the size of the following arrays:
The array indices start at 0 and end at message_header_count - 1.Data Type
i32
message_header_field property (MIME Struct)
This property contains the name of the HTTP header (this is the same case as it is delivered).
Syntax
fn message_header_field(&self , MessageHeaderIndex : i32) -> Result<String, IPWorksSMIMEError>
fn set_message_header_field(&self, MessageHeaderIndex : i32, value : &str) -> Option<IPWorksSMIMEError> fn set_message_header_field_ref(&self, MessageHeaderIndex : i32, value : &String) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
This property contains the name of the HTTP Header (this is the same case as it is delivered).
The MessageHeaderIndex parameter specifies the index of the item in the array. The size of the array is controlled by the MessageHeaderCount property.
Data Type
String
message_header_value property (MIME Struct)
This property contains the header contents.
Syntax
fn message_header_value(&self , MessageHeaderIndex : i32) -> Result<String, IPWorksSMIMEError>
fn set_message_header_value(&self, MessageHeaderIndex : i32, value : &str) -> Option<IPWorksSMIMEError> fn set_message_header_value_ref(&self, MessageHeaderIndex : i32, value : &String) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
This property contains the Header contents.
The MessageHeaderIndex parameter specifies the index of the item in the array. The size of the array is controlled by the MessageHeaderCount property.
Data Type
String
message_headers_string property (MIME Struct)
This property includes the string version of the MIME message headers.
Syntax
fn message_headers_string(&self ) -> Result<String, IPWorksSMIMEError>
fn set_message_headers_string(&self, value : &str) -> Option<IPWorksSMIMEError> fn set_message_headers_string_ref(&self, value : &String) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
The component fills out message_headers_string 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 struct will try to find the headers in the beginning of the message and will fill out this property accordingly.
Data Type
String
part_count property (MIME Struct)
The number of records in the Part arrays.
Syntax
fn part_count(&self ) -> Result<i32, IPWorksSMIMEError>
fn set_part_count(&self, value : i32) -> Option<IPWorksSMIMEError>
Default Value
0
Remarks
This property controls the size of the following arrays:
- part_content_disposition
- part_content_disposition_attr
- part_content_id
- part_content_type
- part_content_type_attr
- part_decoded_file
- part_decoded_string
- part_encoding
- part_file_name
- part_headers
- part_name
- part_size
Data Type
i32
part_content_disposition property (MIME Struct)
This property contains content disposition for each part.
Syntax
fn part_content_disposition(&self , PartIdx : i32) -> Result<String, IPWorksSMIMEError>
fn set_part_content_disposition(&self, PartIdx : i32, value : &str) -> Option<IPWorksSMIMEError> fn set_part_content_disposition_ref(&self, PartIdx : i32, value : &String) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
This property contains content disposition for each part.
The value in this property is used in the Content-Disposition header. Typical values include "form-data" and "attachment". The struct fills it out each time the part_decoded_file is changed. Changing the part_content_disposition recalculates the part_headers as well.
The PartIdx parameter specifies the index of the item in the array. The size of the array is controlled by the PartCount property.
Data Type
String
part_content_disposition_attr property (MIME Struct)
This property contains the content disposition's attribute (if any) for each part.
Syntax
fn part_content_disposition_attr(&self , PartIdx : i32) -> Result<String, IPWorksSMIMEError>
fn set_part_content_disposition_attr(&self, PartIdx : i32, value : &str) -> Option<IPWorksSMIMEError> fn set_part_content_disposition_attr_ref(&self, PartIdx : i32, value : &String) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
This property contains the content disposition's attribute (if any) for each part.
Typical values for this property are the names of the form-variables used while creating an HTTP post or the values for filenames.
Setting this property recalculates the part_headers.
The PartIdx parameter specifies the index of the item in the array. The size of the array is controlled by the PartCount property.
Data Type
String
part_content_id property (MIME Struct)
This property contains the content identifier for each part.
Syntax
fn part_content_id(&self , PartIdx : i32) -> Result<String, IPWorksSMIMEError>
fn set_part_content_id(&self, PartIdx : i32, value : &str) -> Option<IPWorksSMIMEError> fn set_part_content_id_ref(&self, PartIdx : i32, value : &String) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
This property contains the content identifier for each part. The value of this property is used in the Content-Id header. The struct fills it out each time the part_decoded_file is changed. Changing this property recalculates the part_headers as well.
The PartIdx parameter specifies the index of the item in the array. The size of the array is controlled by the PartCount property.
Data Type
String
part_content_type property (MIME Struct)
This property contains the content type for each part.
Syntax
fn part_content_type(&self , PartIdx : i32) -> Result<String, IPWorksSMIMEError>
fn set_part_content_type(&self, PartIdx : i32, value : &str) -> Option<IPWorksSMIMEError> fn set_part_content_type_ref(&self, PartIdx : i32, value : &String) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
This property contains the content type for each part. The value of this property is used in the Content-Type header. Typical values include "image/gif" and "text/plain". The struct fills it out each time the part_decoded_file is changed. Changing this property recalculates the part_headers as well.
The PartIdx parameter specifies the index of the item in the array. The size of the array is controlled by the PartCount property.
Data Type
String
part_content_type_attr property (MIME Struct)
This property contains the content-type attribute, if any, for each part.
Syntax
fn part_content_type_attr(&self , PartIdx : i32) -> Result<String, IPWorksSMIMEError>
fn set_part_content_type_attr(&self, PartIdx : i32, value : &str) -> Option<IPWorksSMIMEError> fn set_part_content_type_attr_ref(&self, PartIdx : i32, value : &String) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
This property contains the content-type attribute, if any, for each part. Setting this recalculates the part_headers as well.
The PartIdx parameter specifies the index of the item in the array. The size of the array is controlled by the PartCount property.
Data Type
String
part_decoded_file property (MIME Struct)
This property may be set to a file on disk before calling EncodeToString , EncodeToFile or EncodeToStream .
Syntax
fn part_decoded_file(&self , PartIdx : i32) -> Result<String, IPWorksSMIMEError>
fn set_part_decoded_file(&self, PartIdx : i32, value : &str) -> Option<IPWorksSMIMEError> fn set_part_decoded_file_ref(&self, PartIdx : i32, value : &String) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
This property may be set to a file on disk before calling encode_to_string, encode_to_file or encode_to_stream. When encoding, data for the part will be read from the specified file.
When decoding, call decode_part_to_file to decode a specific part to a file on disk.
The PartIdx parameter specifies the index of the item in the array. The size of the array is controlled by the PartCount property.
Data Type
String
part_decoded_string property (MIME Struct)
This property holds the actual content of each part.
Syntax
fn part_decoded_string(&self , PartIdx : i32) -> Result<Vec<u8>, IPWorksSMIMEError>
fn set_part_decoded_string(&self, PartIdx : i32, value : Vec<u8>) -> Option<IPWorksSMIMEError> fn set_part_decoded_string_ref(&self, PartIdx : i32, value : &[u8]) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
This property holds the actual content of each part. The struct decodes the actual part of message to part_decoded_string when part_decoded_string's value is first queried.
Setting a value to part_decoded_string fills out the corresponding part_size with the string size if the corresponding part_decoded_file is empty.
The struct checks during encoding first part_decoded_file: if it is empty, then the struct uses the value of part_decoded_string.
NOTE: It is recommended to use the decode_part method instead of querying this property.
The PartIdx parameter specifies the index of the item in the array. The size of the array is controlled by the PartCount property.
Data Type
Vec
part_encoding property (MIME Struct)
This property contains the actual content encoding type for each part.
Syntax
fn part_encoding(&self , PartIdx : i32) -> Result<i32, IPWorksSMIMEError>
fn set_part_encoding(&self, PartIdx : i32, value : i32) -> Option<IPWorksSMIMEError>
Possible Values
0 // 7Bit
1 // QuotedPrintable
2 // Base64
3 // 8Bit
4 // Binary
5 // UUEncode
Default Value
0
Remarks
This property contains the actual content encoding type for each part. This property 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 property 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. |
The PartIdx parameter specifies the index of the item in the array. The size of the array is controlled by the PartCount property.
Data Type
i32
part_file_name property (MIME Struct)
This property contains the filename attribute specified in the headers of the part.
Syntax
fn part_file_name(&self , PartIdx : i32) -> Result<String, IPWorksSMIMEError>
fn set_part_file_name(&self, PartIdx : i32, value : &str) -> Option<IPWorksSMIMEError> fn set_part_file_name_ref(&self, PartIdx : i32, value : &String) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
This property contains the filename attribute specified in the headers of the part. Changing the value of the corresponding part_decoded_file automatically sets the part_file_name and consequently the part_headers.
The PartIdx parameter specifies the index of the item in the array. The size of the array is controlled by the PartCount property.
Data Type
String
part_headers property (MIME Struct)
This property contains the headers for each MIME part.
Syntax
fn part_headers(&self , PartIdx : i32) -> Result<String, IPWorksSMIMEError>
fn set_part_headers(&self, PartIdx : i32, value : &str) -> Option<IPWorksSMIMEError> fn set_part_headers_ref(&self, PartIdx : i32, value : &String) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
This property contains the headers for each MIME part. The struct fills out this property 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.
The PartIdx parameter specifies the index of the item in the array. The size of the array is controlled by the PartCount property.
Data Type
String
part_name property (MIME Struct)
This property contains the name given to a part, such as the filename.
Syntax
fn part_name(&self , PartIdx : i32) -> Result<String, IPWorksSMIMEError>
fn set_part_name(&self, PartIdx : i32, value : &str) -> Option<IPWorksSMIMEError> fn set_part_name_ref(&self, PartIdx : i32, value : &String) -> Option<IPWorksSMIMEError>
Default Value
""
Remarks
This property contains the name given to a part, such as the filename. Changing the value of part_decoded_file automatically sets the corresponding part_name and consequently the part_headers.
The PartIdx parameter specifies the index of the item in the array. The size of the array is controlled by the PartCount property.
Data Type
String
part_size property (MIME Struct)
This property contains the size of the DecodedFile or DecodedString .
Syntax
fn part_size(&self , PartIdx : i32) -> Result<i32, IPWorksSMIMEError>
Default Value
0
Remarks
This property contains the size of the part_decoded_file or part_decoded_string. If a non-empty value is assigned to part_decoded_file, then struct fills out the corresponding part_size with the file size; if the file does not exist, an error occurs.
If the part_decoded_file is empty and a value is assigned to part_decoded_string, then the corresponding part_size will be equal to the string's size.
During decoding, this property is filled with the size of that part.
The PartIdx parameter specifies the index of the item in the array. The size of the array is controlled by the PartCount property.
This property is read-only.
Data Type
i32
config method (MIME Struct)
Sets or retrieves a configuration setting.
Syntax
fn config(&self, configuration_string : &str) -> Result<String, IPWorksSMIMEError>
Remarks
config is a generic method available in every struct. It is used to set and retrieve configuration settings for the struct.
These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the struct, 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.
decode_from_file method (MIME Struct)
This method decodes from a file.
Syntax
fn decode_from_file(&self) -> Result<(), IPWorksSMIMEError>
Remarks
This method decodes the data file given in message and optionally message_headers 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 message_headers property must be set to the appropriate MIME headers.
decode_from_string method (MIME Struct)
This method decodes from a string.
Syntax
fn decode_from_string(&self) -> Result<(), IPWorksSMIMEError>
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 message_headers and fills out the parts properties.
Example. Decoding a Mail Message:
MIMEControl.MessageHeadersString = MailControl.MessageHeaders
MIMEControl.Message = MailControl.MessageText
MIMEControl.DecodeFromString
decode_part method (MIME Struct)
This method decodes the specified part.
Syntax
fn decode_part(&self, index : i32) -> Result<Vec<u8>, IPWorksSMIMEError>
Remarks
This method decodes the part specified by index and returns the decoded part data.
decode_from_string or decode_from_file must be called before calling this method. Calling this method will return the decoded bytes, and in addition, the part_decoded_string property 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);
decode_part_to_file method (MIME Struct)
This method decodes the specified part to a file on disk.
Syntax
fn decode_part_to_file(&self, index : i32) -> Result<String, IPWorksSMIMEError>
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.
decode_from_string or decode_from_file must be called before calling this method.
encode_to_file method (MIME Struct)
This method encodes to a file.
Syntax
fn encode_to_file(&self) -> Result<(), IPWorksSMIMEError>
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 message_headers 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 struct 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 message_headers.
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()
encode_to_string method (MIME Struct)
This method encodes to a string.
Syntax
fn encode_to_string(&self) -> Result<(), IPWorksSMIMEError>
Remarks
This method encodes to a string. It is the same as encode_to_file 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 message_headers 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 reset_data.
The struct 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 message_headers.
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()
reset method (MIME Struct)
This method will reset the struct.
Syntax
fn reset(&self) -> Result<(), IPWorksSMIMEError>
Remarks
This method will reset the struct's properties to their default values.
reset_data method (MIME Struct)
This method resets the values of all headers and part properties.
Syntax
fn reset_data(&self) -> Result<(), IPWorksSMIMEError>
Remarks
This method resets the values of all headers and part properties. It is an easy way to reset the struct's properties before starting to populate the part properties with new values.
on_error event (MIME Struct)
Fired when information is available about errors during data delivery.
Syntax
// MIMEErrorEventArgs carries the MIME Error event's parameters.
pub struct MIMEErrorEventArgs {
fn error_code(&self) -> i32
fn description(&self) -> &String
}
// MIMEErrorEvent defines the signature of the MIME Error event's handler function.
pub trait MIMEErrorEvent {
fn on_error(&self, sender : MIME, e : &mut MIMEErrorEventArgs);
}
impl <'a> MIME<'a> {
pub fn on_error(&self) -> &'a dyn MIMEErrorEvent;
pub fn set_on_error(&mut self, value : &'a dyn MIMEErrorEvent);
...
}
Remarks
The on_error event is fired in case of exceptional conditions during message processing. Normally the struct fails with an error.
The error_code 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.
on_header event (MIME Struct)
This event is fired every time a header is parsed.
Syntax
// MIMEHeaderEventArgs carries the MIME Header event's parameters.
pub struct MIMEHeaderEventArgs {
fn part_index(&self) -> i32
fn field(&self) -> &String
fn value(&self) -> &[u8]
}
// MIMEHeaderEvent defines the signature of the MIME Header event's handler function.
pub trait MIMEHeaderEvent {
fn on_header(&self, sender : MIME, e : &mut MIMEHeaderEventArgs);
}
impl <'a> MIME<'a> {
pub fn on_header(&self) -> &'a dyn MIMEHeaderEvent;
pub fn set_on_header(&mut self, value : &'a dyn MIMEHeaderEvent);
...
}
Remarks
The part_index 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 on_header event is fired when a header is parsed, which occurs for each header of the message when decode_from_file, decode_from_string, or decode_from_stream is called.
on_progress event (MIME Struct)
This event shows the progress of decoding or encoding the input data.
Syntax
// MIMEProgressEventArgs carries the MIME Progress event's parameters.
pub struct MIMEProgressEventArgs {
fn percent_done(&self) -> i32
}
// MIMEProgressEvent defines the signature of the MIME Progress event's handler function.
pub trait MIMEProgressEvent {
fn on_progress(&self, sender : MIME, e : &mut MIMEProgressEventArgs);
}
impl <'a> MIME<'a> {
pub fn on_progress(&self) -> &'a dyn MIMEProgressEvent;
pub fn set_on_progress(&mut self, value : &'a dyn MIMEProgressEvent);
...
}
Remarks
The on_progress allows the user to visualize the progress of processing the input data.
The percent_done parameter shows what percentage of the input has been read.
Config Settings (MIME Struct)
The struct 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 struct, 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.
Setting this configuration setting to true tells the struct 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 Struct)
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 struct 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. |