## GMimePart GMimePart — MIME parts |

## Synopsis

                        GMimePart;
    GMimePart*          g_mime_part_new                     (void);
    GMimePart*          g_mime_part_new_with_type           (const char *type,
                                                             const char *subtype);
    void                g_mime_part_set_content_header      (GMimePart *mime_part,
                                                             const char *header,
                                                             const char *value);
    const char*         g_mime_part_get_content_header      (GMimePart *mime_part,
                                                             const char *header);
    void                g_mime_part_set_content_description (GMimePart *mime_part,
                                                             const char *description);
    const char*         g_mime_part_get_content_description (const GMimePart *mime_part);
    void                g_mime_part_set_content_id          (GMimePart *mime_part,
                                                             const char *content_id);
    const char*         g_mime_part_get_content_id          (GMimePart *mime_part);
    void                g_mime_part_set_content_md5         (GMimePart *mime_part,
                                                             const char *content_md5);
    const char*         g_mime_part_get_content_md5         (GMimePart *mime_part);
    gboolean            g_mime_part_verify_content_md5      (GMimePart *mime_part);
    void                g_mime_part_set_content_location    (GMimePart *mime_part,
                                                             const char *content_location);
    const char*         g_mime_part_get_content_location    (GMimePart *mime_part);
    void                g_mime_part_set_content_type        (GMimePart *mime_part,
                                                             GMimeContentType *mime_type);
    const GMimeContentType* g_mime_part_get_content_type    (GMimePart *mime_part);
    void                g_mime_part_set_encoding            (GMimePart *mime_part,
                                                             GMimePartEncodingType encoding);
    GMimePartEncodingType g_mime_part_get_encoding          (GMimePart *mime_part);
    const char*         g_mime_part_encoding_to_string      (GMimePartEncodingType encoding);
    GMimePartEncodingType g_mime_part_encoding_from_string  (const char *encoding);
    void                g_mime_part_set_content_disposition_object
                                                            (GMimePart *mime_part,
                                                             GMimeDisposition *disposition);
    void                g_mime_part_set_content_disposition (GMimePart *mime_part,
                                                             const char *disposition);
    const char*         g_mime_part_get_content_disposition (GMimePart *mime_part);
    void                g_mime_part_add_content_disposition_parameter
                                                            (GMimePart *mime_part,
                                                             const char *attribute,
                                                             const char *value);
    const char*         g_mime_part_get_content_disposition_parameter
                                                            (GMimePart *mime_part,
                                                             const char *attribute);
    void                g_mime_part_set_filename            (GMimePart *mime_part,
                                                             const char *filename);
    const char*         g_mime_part_get_filename            (const GMimePart *mime_part);
    void                g_mime_part_set_content             (GMimePart *mime_part,
                                                             const char *content,
                                                             size_t len);
    void                g_mime_part_set_pre_encoded_content (GMimePart *mime_part,
                                                             const char *content,
                                                             size_t len,
                                                             GMimePartEncodingType encoding);
    void                g_mime_part_set_content_byte_array  (GMimePart *mime_part,
                                                             GByteArray *content);
    const char*         g_mime_part_get_content             (const GMimePart *mime_part,
                                                             size_t *len);
    GMimeDataWrapper*   g_mime_part_get_content_object      (const GMimePart *mime_part);
    void                g_mime_part_set_content_object      (GMimePart *mime_part,
                                                             GMimeDataWrapper *content);
    ssize_t             g_mime_part_write_to_stream         (GMimePart *mime_part,
                                                             GMimeStream *stream);
    char*               g_mime_part_to_string               (GMimePart *mime_part);

## Object Hierarchy

      GObject
       +----GMimeObject
             +----GMimePart
                   +----GMimeMessagePartial

## Description

A GMimePart represents any MIME leaf part (meaning it has no sub-parts).

## Details

### GMimePart

    typedef struct _GMimePart GMimePart;

### g_mime_part_new ()

    GMimePart*          g_mime_part_new                     (void);

Creates a new MIME Part object with a default content-type of text/plain.

Returns : | an empty MIME Part object with a default content-type of text/plain.

### g_mime_part_new_with_type ()

    GMimePart*          g_mime_part_new_with_type           (const char *type,
                                                             const char *subtype);

Creates a new MIME Part with a sepcified type.

`type` : | content-type
`subtype` : | content-subtype
Returns : | an empty MIME Part object with the specified content-type.

### g_mime_part_set_content_header ()

    void                g_mime_part_set_content_header      (GMimePart *mime_part,
                                                             const char *header,
                                                             const char *value);

Set an arbitrary MIME content header.

`mime_part` : | mime part
`header` : | header name
`value` : | header value

### g_mime_part_get_content_header ()

    const char*         g_mime_part_get_content_header      (GMimePart *mime_part,
                                                             const char *header);

Gets the value of the requested header if it exists, or `NULL` otherwise.

`mime_part` : | mime part
`header` : | header name
Returns : | the value of the content header `header`.

### g_mime_part_set_content_description ()

    void                g_mime_part_set_content_description (GMimePart *mime_part,
                                                             const char *description);

Set the content description for the specified mime part.

`mime_part` : | Mime part
`description` : | content description

### g_mime_part_get_content_description ()

    const char*         g_mime_part_get_content_description (const GMimePart *mime_part);

Gets the value of the Content-Description for the specified mime part if it exists or `NULL` otherwise.

`mime_part` : | Mime part
Returns : | the content description for the specified mime part.

### g_mime_part_set_content_id ()

    void                g_mime_part_set_content_id          (GMimePart *mime_part,
                                                             const char *content_id);

Set the content id for the specified mime part.

`mime_part` : | Mime part
`content_id` : | content id

### g_mime_part_get_content_id ()

    const char*         g_mime_part_get_content_id          (GMimePart *mime_part);

Gets the content-id of the specified mime part if it exists, or `NULL` otherwise.

`mime_part` : | Mime part
Returns : | the content id for the specified mime part.

### g_mime_part_set_content_md5 ()

    void                g_mime_part_set_content_md5         (GMimePart *mime_part,
                                                             const char *content_md5);

Set the content md5 for the specified mime part.

`mime_part` : | Mime part
`content_md5` : | content md5 or `NULL` to generate the md5 digest.

### g_mime_part_get_content_md5 ()

    const char*         g_mime_part_get_content_md5         (GMimePart *mime_part);

Gets the md5sum contained in the Content-Md5 header of the specified mime part if it exists, or `NULL` otherwise.

`mime_part` : | Mime part
Returns : | the content md5 for the specified mime part.

### g_mime_part_verify_content_md5 ()

    gboolean            g_mime_part_verify_content_md5      (GMimePart *mime_part);

Verify the content md5 for the specified mime part.

`mime_part` : | Mime part
Returns : | `TRUE` if the md5 is valid or `FALSE` otherwise. Note: will return `FALSE` if the mime part does not contain a Content-MD5.

### g_mime_part_set_content_location ()

    void                g_mime_part_set_content_location    (GMimePart *mime_part,
                                                             const char *content_location);

Set the content location for the specified mime part.

`mime_part` : | Mime part
`content_location` : | content location

### g_mime_part_get_content_location ()

    const char*         g_mime_part_get_content_location    (GMimePart *mime_part);

Gets the value of the Content-Location header if it exists, or `NULL` otherwise.

`mime_part` : | Mime part
Returns : | the content location for the specified mime part.

### g_mime_part_set_content_type ()

    void                g_mime_part_set_content_type        (GMimePart *mime_part,
                                                             GMimeContentType *mime_type);

### Warning

`g_mime_part_set_content_type` is deprecated and should not be used in newly-written code.

Set the content type/subtype for the specified mime part.

WARNING: This interface is deprecated. Use `g_mime_object_set_content_type()`.

`mime_part` : | Mime part
`mime_type` : | Mime content-type

### g_mime_part_get_content_type ()

    const GMimeContentType* g_mime_part_get_content_type    (GMimePart *mime_part);

### Warning

`g_mime_part_get_content_type` is deprecated and should not be used in newly-written code.

Gets the Content-Type object for the given mime part or `NULL` on error.

WARNING: This interface is deprecated. Use `g_mime_object_get_content_type()`.

`mime_part` : | Mime part
Returns : | the content-type object for the specified mime part.

### g_mime_part_set_encoding ()

    void                g_mime_part_set_encoding            (GMimePart *mime_part,
                                                             GMimePartEncodingType encoding);

Set the content encoding for the specified mime part. Available values for the encoding are: GMIME_PART_ENCODING_DEFAULT, GMIME_PART_ENCODING_7BIT, GMIME_PART_ENCODING_8BIT, GMIME_PART_ENCODING_BINARY, GMIME_PART_ENCODING_BASE64 and GMIME_PART_ENCODING_QUOTEDPRINTABLE.

`mime_part` : | Mime part
`encoding` : | Mime encoding

### g_mime_part_get_encoding ()

    GMimePartEncodingType g_mime_part_get_encoding          (GMimePart *mime_part);

Gets the content encoding of the mime part.

`mime_part` : | Mime part
Returns : | the content encoding for the specified mime part. The return value will be one of the following: GMIME_PART_ENCODING_DEFAULT, GMIME_PART_ENCODING_7BIT, GMIME_PART_ENCODING_8BIT, GMIME_PART_ENCODING_BINARY, GMIME_PART_ENCODING_BASE64, GMIME_PART_ENCODING_QUOTEDPRINTABLE or GMIME_PART_ENCODING_UUENCODE.

### g_mime_part_encoding_to_string ()

    const char*         g_mime_part_encoding_to_string      (GMimePartEncodingType encoding);

Gets the string value of the content encoding.

`encoding` : | Mime encoding
Returns : | the encoding type as a string. Available values for the encoding are: GMIME_PART_ENCODING_DEFAULT, GMIME_PART_ENCODING_7BIT, GMIME_PART_ENCODING_8BIT, GMIME_PART_ENCODING_BINARY, GMIME_PART_ENCODING_BASE64, GMIME_PART_ENCODING_QUOTEDPRINTABLE and GMIME_PART_ENCODING_UUENCODE.

### g_mime_part_encoding_from_string ()

    GMimePartEncodingType g_mime_part_encoding_from_string  (const char *encoding);

Gets the content encoding enumeration value based on the input string.

`encoding` : | Mime encoding in string format
Returns : | the encoding string as a GMimePartEncodingType. Available values for the encoding are: GMIME_PART_ENCODING_DEFAULT, GMIME_PART_ENCODING_7BIT, GMIME_PART_ENCODING_8BIT, GMIME_PART_ENCODING_BINARY, GMIME_PART_ENCODING_BASE64, GMIME_PART_ENCODING_QUOTEDPRINTABLE and GMIME_PART_ENCODING_UUENCODE.

### g_mime_part_set_content_disposition_object ()

    void                g_mime_part_set_content_disposition_object
                                                            (GMimePart *mime_part,
                                                             GMimeDisposition *disposition);

Set the content disposition for the specified mime part

`mime_part` : | Mime part
`disposition` : | disposition object

### g_mime_part_set_content_disposition ()

    void                g_mime_part_set_content_disposition (GMimePart *mime_part,
                                                             const char *disposition);

Set the content disposition for the specified mime part

`mime_part` : | Mime part
`disposition` : | disposition

### g_mime_part_get_content_disposition ()

    const char*         g_mime_part_get_content_disposition (GMimePart *mime_part);

Gets the content disposition if set or `NULL` otherwise.

`mime_part` : | Mime part
Returns : | the content disposition for the specified mime part.

### g_mime_part_add_content_disposition_parameter ()

    void                g_mime_part_add_content_disposition_parameter
                                                            (GMimePart *mime_part,
                                                             const char *attribute,
                                                             const char *value);

Add a content-disposition parameter to the specified mime part.

`mime_part` : | Mime part
`attribute` : | parameter name
`value` : | parameter value

### g_mime_part_get_content_disposition_parameter ()

    const char*         g_mime_part_get_content_disposition_parameter
                                                            (GMimePart *mime_part,
                                                             const char *attribute);

Gets the value of the Content-Disposition parameter specified by `attribute`, or `NULL` if the parameter does not exist.

`mime_part` : | Mime part
`attribute` : | parameter name
Returns : | the value of a previously defined content-disposition parameter specified by `attribute`.

### g_mime_part_set_filename ()

    void                g_mime_part_set_filename            (GMimePart *mime_part,
                                                             const char *filename);

Sets the "filename" parameter on the Content-Disposition and also sets the "name" parameter on the Content-Type.

`mime_part` : | Mime part
`filename` : | the filename of the Mime Part's content

### g_mime_part_get_filename ()

    const char*         g_mime_part_get_filename            (const GMimePart *mime_part);

Gets the filename of the specificed mime part, or `NULL` if the mime part does not have the filename or name parameter set.

`mime_part` : | Mime part
Returns : | the filename of the specified MIME Part. It first checks to see if the "filename" parameter was set on the Content-Disposition and if not then checks the "name" parameter in the Content-Type.

### g_mime_part_set_content ()

    void                g_mime_part_set_content             (GMimePart *mime_part,
                                                             const char *content,
                                                             size_t len);

### Warning

`g_mime_part_set_content` is deprecated and should not be used in newly-written code.

WARNING: This interface is deprecated. Use `g_mime_part_set_content_object()` instead.

Sets the content of the Mime Part (only non-multiparts)

`mime_part` : | Mime part
`content` : | raw mime part content
`len` : | raw content length

### g_mime_part_set_pre_encoded_content ()

    void                g_mime_part_set_pre_encoded_content (GMimePart *mime_part,
                                                             const char *content,
                                                             size_t len,
                                                             GMimePartEncodingType encoding);

### Warning

`g_mime_part_set_pre_encoded_content` is deprecated and should not be used in newly-written code.

WARNING: This interface is deprecated. Use `g_mime_part_set_content_object()` instead.

Sets the encoding type and raw content on the mime part after decoding the content.

`mime_part` : | Mime part
`content` : | encoded mime part content
`len` : | length of the content
`encoding` : | content encoding

### g_mime_part_set_content_byte_array ()

    void                g_mime_part_set_content_byte_array  (GMimePart *mime_part,
                                                             GByteArray *content);

### Warning

`g_mime_part_set_content_byte_array` is deprecated and should not be used in newly-written code.

WARNING: This interface is deprecated. Use `g_mime_part_set_content_object()` instead.

Sets the content of the Mime Part (only non-multiparts)

`mime_part` : | Mime part
`content` : | raw mime part content.

### g_mime_part_get_content ()

    const char*         g_mime_part_get_content             (const GMimePart *mime_part,
                                                             size_t *len);

### Warning

`g_mime_part_get_content` is deprecated and should not be used in newly-written code.

Gets the raw contents of the mime part and sets `len` to the length of the raw data buffer.

WARNING: This interface is deprecated. Use `g_mime_part_get_content_object()` instead.

`mime_part` : | MIME part object
`len` : | pointer to the content length
Returns : | a const char * pointer to the raw contents of the MIME Part and sets `len` to the length of the buffer. Note: textual content will not be converted to UTF-8. Also note that this buffer will not be nul-terminated and may in fact contain nul bytes mid-buffer so you MUST treat the data returned as raw binary data even if the content type is text.

### g_mime_part_get_content_object ()

    GMimeDataWrapper*   g_mime_part_get_content_object      (const GMimePart *mime_part);

Gets the internal data-wrapper of the specified mime part, or `NULL` on error.

`mime_part` : | MIME part object
Returns : | the data-wrapper for the mime part's contents.

### g_mime_part_set_content_object ()

    void                g_mime_part_set_content_object      (GMimePart *mime_part,
                                                             GMimeDataWrapper *content);

Sets the content object on the mime part.

`mime_part` : | MIME Part
`content` : | content object

### g_mime_part_write_to_stream ()

    ssize_t             g_mime_part_write_to_stream         (GMimePart *mime_part,
                                                             GMimeStream *stream);

### Warning

`g_mime_part_write_to_stream` is deprecated and should not be used in newly-written code.

Writes the contents of the MIME Part to `stream`.

WARNING: This interface is deprecated. Use `g_mime_object_write_to_stream()` instead.

`mime_part` : | MIME Part
`stream` : | output stream
Returns : | the number of bytes written or `-1` on fail.

### g_mime_part_to_string ()

    char*               g_mime_part_to_string               (GMimePart *mime_part);

### Warning

`g_mime_part_to_string` is deprecated and should not be used in newly-written code.

Allocates a string buffer containing the MIME Part.

WARNING: This interface is deprecated. Use `g_mime_object_to_string()` instead.

`mime_part` : | MIME Part
Returns : | an allocated string containing the MIME Part.