CamelMimePart: Camel Reference Manual

## CamelMimePart CamelMimePart |

## Functions

gchar * | (*CamelGeneratePreviewFunc) ()
CamelMimePart * | camel_mime_part_new ()
void | camel_mime_part_set_description ()
const gchar * | camel_mime_part_get_description ()
void | camel_mime_part_set_disposition ()
const gchar * | camel_mime_part_get_disposition ()
const CamelContentDisposition * | camel_mime_part_get_content_disposition ()
void | camel_mime_part_set_filename ()
const gchar * | camel_mime_part_get_filename ()
void | camel_mime_part_set_content_id ()
const gchar * | camel_mime_part_get_content_id ()
void | camel_mime_part_set_content_md5 ()
const gchar * | camel_mime_part_get_content_md5 ()
void | camel_mime_part_set_content_location ()
const gchar * | camel_mime_part_get_content_location ()
void | camel_mime_part_set_encoding ()
CamelTransferEncoding | camel_mime_part_get_encoding ()
void | camel_mime_part_set_content_languages ()
const GList * | camel_mime_part_get_content_languages ()
void | camel_mime_part_set_content_type ()
CamelContentType * | camel_mime_part_get_content_type ()
void | camel_mime_part_set_content ()
gboolean | camel_mime_part_construct_from_parser_sync ()
void | camel_mime_part_construct_from_parser ()
gboolean | camel_mime_part_construct_from_parser_finish ()
gchar * | camel_mime_part_generate_preview ()

## Properties

char * | content-id | Read / Write
char * | content-md5 | Read / Write
char * | description | Read / Write
char * | disposition | Read / Write

## Types and Values

#define | CAMEL_MAX_PREVIEW_LENGTH

## Object Hierarchy

        GObject
        ╰── CamelDataWrapper
            ╰── CamelMedium
                ╰── CamelMimePart
                    ╰── CamelMimeMessage

## Description

## Functions

### CamelGeneratePreviewFunc ()

    gchar *
    (*CamelGeneratePreviewFunc) (gpointer part,
                                 gpointer user_data);

A custom function to generate preview text for the content of the `part` . The `part` can be either a CamelMimePart or a CamelMultipart, depending in which context it is called.

The preview is supposed to be up to `CAMEL_MAX_PREVIEW_LENGTH` characters long, in a plain text format.

#### Parameters

part | either a CamelMimePart or a CamelMultipart |
user_data | user data for the function |

#### Returns

valid UTF-8 encoded preview text for the `part` , or `NULL`, when cannot handle the `part` .

[nullable][transfer full]

Since: 3.52

### camel_mime_part_new ()

    CamelMimePart *
    camel_mime_part_new (void);

Create a new MIME part.

#### Returns

a new CamelMimePart

### camel_mime_part_set_description ()

    void
    camel_mime_part_set_description (CamelMimePart *mime_part,
                                     const gchar *description);

Set a description on the MIME part.

#### Parameters

mime_part | a CamelMimePart |
description | description of the MIME part |

### camel_mime_part_get_description ()

    const gchar *
    camel_mime_part_get_description (CamelMimePart *mime_part);

Get the description of the MIME part.

#### Parameters

mime_part | a CamelMimePart |

#### Returns

the description.

[nullable]

### camel_mime_part_set_disposition ()

    void
    camel_mime_part_set_disposition (CamelMimePart *mime_part,
                                     const gchar *disposition);

Set a disposition on the MIME part.

#### Parameters

mime_part | a CamelMimePart |
disposition | disposition of the MIME part. | [nullable]

### camel_mime_part_get_disposition ()

    const gchar *
    camel_mime_part_get_disposition (CamelMimePart *mime_part);

Get the disposition of the MIME part.

#### Parameters

mime_part | a CamelMimePart |

#### Returns

the disposition.

[nullable]

### camel_mime_part_get_content_disposition ()

    const CamelContentDisposition *
    camel_mime_part_get_content_disposition
                                   (CamelMimePart *mime_part);

Get the disposition of the MIME part as a structure. Returned pointer is owned by `mime_part` .

#### Parameters

mime_part | a CamelMimePart |

#### Returns

the disposition structure.

[nullable]

Since: 2.30

### camel_mime_part_set_filename ()

    void
    camel_mime_part_set_filename (CamelMimePart *mime_part,
                                  const gchar *filename);

Set the filename on a MIME part.

#### Parameters

mime_part | a CamelMimePart |
filename | filename given to the MIME part. | [nullable]

### camel_mime_part_get_filename ()

    const gchar *
    camel_mime_part_get_filename (CamelMimePart *mime_part);

Get the filename of a MIME part.

#### Parameters

mime_part | a CamelMimePart |

#### Returns

the filename of the MIME part.

[nullable]

### camel_mime_part_set_content_id ()

    void
    camel_mime_part_set_content_id (CamelMimePart *mime_part,
                                    const gchar *contentid);

Set the content-id field on a MIME part.

#### Parameters

mime_part | a CamelMimePart |
contentid | content id. | [nullable]

### camel_mime_part_get_content_id ()

    const gchar *
    camel_mime_part_get_content_id (CamelMimePart *mime_part);

Get the content-id field of a MIME part.

#### Parameters

mime_part | a CamelMimePart |

#### Returns

the content-id field of the MIME part.

[nullable]

### camel_mime_part_set_content_md5 ()

    void
    camel_mime_part_set_content_md5 (CamelMimePart *mime_part,
                                     const gchar *md5sum);

Set the content-md5 field of the MIME part.

#### Parameters

mime_part | a CamelMimePart |
md5sum | the md5sum of the MIME part. | [nullable]

### camel_mime_part_get_content_md5 ()

    const gchar *
    camel_mime_part_get_content_md5 (CamelMimePart *mime_part);

Get the content-md5 field of the MIME part.

#### Parameters

mime_part | a CamelMimePart |

#### Returns

the content-md5 field of the MIME part.

[nullable]

### camel_mime_part_set_content_location ()

    void
    camel_mime_part_set_content_location (CamelMimePart *mime_part,
                                          const gchar *location);

Set the content-location field of the MIME part.

#### Parameters

mime_part | a CamelMimePart |
location | the content-location value of the MIME part. | [nullable]

### camel_mime_part_get_content_location ()

    const gchar *
    camel_mime_part_get_content_location (CamelMimePart *mime_part);

Get the content-location field of a MIME part.

#### Parameters

mime_part | a CamelMimePart |

#### Returns

the content-location field of a MIME part.

[nullable]

### camel_mime_part_set_encoding ()

    void
    camel_mime_part_set_encoding (CamelMimePart *mime_part,
                                  CamelTransferEncoding encoding);

Set the Content-Transfer-Encoding to use on a MIME part.

#### Parameters

mime_part | a CamelMimePart |
encoding | a CamelTransferEncoding |

### camel_mime_part_get_encoding ()

    CamelTransferEncoding
    camel_mime_part_get_encoding (CamelMimePart *mime_part);

Get the Content-Transfer-Encoding of a MIME part.

#### Parameters

mime_part | a CamelMimePart |

#### Returns

a CamelTransferEncoding

### camel_mime_part_set_content_languages ()

    void
    camel_mime_part_set_content_languages (CamelMimePart *mime_part,
                                           GList *content_languages);

Set the Content-Languages field of a MIME part.

#### Parameters

mime_part | a CamelMimePart |
content_languages | list of languages. | [element-type utf8][nullable][transfer full]

### camel_mime_part_get_content_languages ()

    const GList *
    camel_mime_part_get_content_languages (CamelMimePart *mime_part);

Get the Content-Languages set on the MIME part.

#### Parameters

mime_part | a CamelMimePart |

#### Returns

a GList of languages.

[element-type utf8][transfer none][nullable]

### camel_mime_part_set_content_type ()

    void
    camel_mime_part_set_content_type (CamelMimePart *mime_part,
                                      const gchar *content_type);

Set the content-type on a MIME part.

#### Parameters

mime_part | a CamelMimePart |
content_type | content-type string. | [nullable]

### camel_mime_part_get_content_type ()

    CamelContentType *
    camel_mime_part_get_content_type (CamelMimePart *mime_part);

Get the Content-Type of a MIME part.

#### Parameters

mime_part | a CamelMimePart |

#### Returns

the parsed CamelContentType of the MIME part.

[transfer none][nullable]

### camel_mime_part_set_content ()

    void
    camel_mime_part_set_content (CamelMimePart *mime_part,
                                 const gchar *data,
                                 gint length,
                                 const gchar *type);

Utility function used to set the content of a mime part object to be the provided data. If `length` is 0, this routine can be used as a way to remove old content (in which case `data` and `type` are ignored and may be `NULL`).

#### Parameters

mime_part | a CamelMimePart |
data | data to put into the part. | [array length=length][nullable][element-type guint8]
length | length of `data` |
type | Content-Type of the data. | [nullable]

### camel_mime_part_construct_from_parser_sync ()

    gboolean
    camel_mime_part_construct_from_parser_sync
                                   (CamelMimePart *mime_part,
                                    CamelMimeParser *parser,
                                    GCancellable *cancellable,
                                    GError **error);

Constructs a MIME part from a parser.

#### Parameters

mime_part | a CamelMimePart |
parser | a CamelMimeParser |
cancellable | optional GCancellable object, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.0

### camel_mime_part_construct_from_parser ()

    void
    camel_mime_part_construct_from_parser (CamelMimePart *mime_part,
                                           CamelMimeParser *parser,
                                           gint io_priority,
                                           GCancellable *cancellable,
                                           GAsyncReadyCallback callback,
                                           gpointer user_data);

Asynchronously constructs a MIME part from a parser.

When the operation is finished, `callback` will be called. You can then call `camel_mime_part_construct_from_parser_finish()` to get the result of the operation.

#### Parameters

mime_part | a CamelMimePart |
parser | a CamelMimeParser |
io_priority | the I/O priority of the request |
cancellable | optional GCancellable object, or `NULL` |
callback | a GAsyncReadyCallback to call when the request is satisfied |
user_data | data to pass to the callback function |

Since: 3.0

### camel_mime_part_construct_from_parser_finish ()

    gboolean
    camel_mime_part_construct_from_parser_finish
                                   (CamelMimePart *mime_part,
                                    GAsyncResult *result,
                                    GError **error);

Finishes the operation started with `camel_mime_part_construct_from_parser()`.

#### Parameters

mime_part | a CamelMimePart |
result | a GAsyncResult |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.0

### camel_mime_part_generate_preview ()

    gchar *
    camel_mime_part_generate_preview (CamelMimePart *mime_part,
                                      CamelGeneratePreviewFunc func,
                                      gpointer user_data);

Generates preview of the `mime_part` , to be used in the interface, read by the users.

The optional `func` can be used to override default preview generation function. If provided, it's always called as the first try on the parts.

#### Parameters

mime_part | a CamelMimePart |
func | an optional CamelGeneratePreviewFunc function, or `NULL`. | [nullable][scope call]
user_data | user data for the `func` , or `NULL`. | [closure func]

#### Returns

part's preview as a new string, or `NULL`, when cannot be generated. Free with `g_free()`, when no longer needed.

[nullable][transfer full]

Since: 3.52

## Types and Values

### CAMEL_MAX_PREVIEW_LENGTH

    #define CAMEL_MAX_PREVIEW_LENGTH 256

Since: 3.52

## Property Details

### The `“content-id”` property

      “content-id”               char *

Owner: CamelMimePart

Flags: Read / Write

Default value: NULL

### The `“content-md5”` property

      “content-md5”              char *

Owner: CamelMimePart

Flags: Read / Write

Default value: NULL

### The `“description”` property

      “description”              char *

Owner: CamelMimePart

Flags: Read / Write

Default value: NULL

### The `“disposition”` property

      “disposition”              char *

Owner: CamelMimePart

Flags: Read / Write

Default value: NULL