xref: /curl/docs/libcurl/curl_mime_addpart.md (revision 5a488251)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_mime_addpart
5Section: 3
6Source: libcurl
7See-also:
8  - curl_mime_data (3)
9  - curl_mime_data_cb (3)
10  - curl_mime_encoder (3)
11  - curl_mime_filedata (3)
12  - curl_mime_filename (3)
13  - curl_mime_headers (3)
14  - curl_mime_init (3)
15  - curl_mime_name (3)
16  - curl_mime_subparts (3)
17  - curl_mime_type (3)
18Protocol:
19  - HTTP
20  - IMAP
21  - SMTP
22Added-in: 7.56.0
23---
24
25# NAME
26
27curl_mime_addpart - append a new empty part to a mime structure
28
29# SYNOPSIS
30
31~~~c
32#include <curl/curl.h>
33
34curl_mimepart *curl_mime_addpart(curl_mime *mime);
35~~~
36
37# DESCRIPTION
38
39curl_mime_addpart(3) creates and appends a new empty part to the given
40mime structure and returns a handle to it. The returned part handle can
41subsequently be populated using functions from the mime API.
42
43*mime* is the handle of the mime structure in which the new part must be
44appended.
45
46# %PROTOCOLS%
47
48# EXAMPLE
49
50~~~c
51int main(void)
52{
53  curl_mime *mime;
54  curl_mimepart *part;
55
56  CURL *curl = curl_easy_init();
57  if(curl) {
58    /* create a mime handle */
59    mime = curl_mime_init(curl);
60
61    /* add a part */
62    part = curl_mime_addpart(mime);
63
64    /* continue and set name + data to the part */
65    curl_mime_data(part, "This is the field data", CURL_ZERO_TERMINATED);
66    curl_mime_name(part, "data");
67  }
68}
69~~~
70
71# %AVAILABILITY%
72
73# RETURN VALUE
74
75A mime part structure handle, or NULL upon failure.
76