1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: curl_mime_subparts 5Section: 3 6Source: libcurl 7See-also: 8 - curl_mime_addpart (3) 9 - curl_mime_init (3) 10--- 11 12# NAME 13 14curl_mime_subparts - set sub-parts of a multipart mime part 15 16# SYNOPSIS 17 18~~~c 19#include <curl/curl.h> 20 21CURLcode curl_mime_subparts(curl_mimepart *part, curl_mime *subparts); 22~~~ 23 24# DESCRIPTION 25 26curl_mime_subparts(3) sets a multipart mime part's content from a mime 27structure. 28 29*part* is a handle to the multipart part. 30 31*subparts* is a mime structure handle holding the sub-parts. After 32curl_mime_subparts(3) succeeds, the mime structure handle belongs to the 33multipart part and must not be freed explicitly. It may however be updated by 34subsequent calls to mime API functions. 35 36Setting a part's contents multiple times is valid: only the value set by the 37last call is retained. It is possible to unassign previous part's contents by 38setting *subparts* to NULL. 39 40# EXAMPLE 41 42~~~c 43 44static char *inline_html = "<title>example</title>"; 45static char *inline_text = "once upon the time"; 46 47int main(void) 48{ 49 CURL *curl = curl_easy_init(); 50 if(curl) { 51 struct curl_slist *slist; 52 53 /* The inline part is an alternative proposing the html and the text 54 versions of the email. */ 55 curl_mime *alt = curl_mime_init(curl); 56 curl_mimepart *part; 57 58 /* HTML message. */ 59 part = curl_mime_addpart(alt); 60 curl_mime_data(part, inline_html, CURL_ZERO_TERMINATED); 61 curl_mime_type(part, "text/html"); 62 63 /* Text message. */ 64 part = curl_mime_addpart(alt); 65 curl_mime_data(part, inline_text, CURL_ZERO_TERMINATED); 66 67 /* Create the inline part. */ 68 part = curl_mime_addpart(alt); 69 curl_mime_subparts(part, alt); 70 curl_mime_type(part, "multipart/alternative"); 71 slist = curl_slist_append(NULL, "Content-Disposition: inline"); 72 curl_mime_headers(part, slist, 1); 73 } 74} 75~~~ 76 77# AVAILABILITY 78 79As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0. 80 81# RETURN VALUE 82 83CURLE_OK or a CURL error code upon failure. 84