Unicode C
Unicode C
Set the Content-Disposition of an Attachment
See more Email Object Examples
Demonstrates the Chilkat Email.SetAttachmentDisposition method, which sets the Content-Disposition value for the attachment at a given zero-based index. The default disposition is attachment. This example changes an attachment's disposition to inline.
Background: The
Content-Disposition header hints how a client should present a part: attachment means "offer it as a download," while inline means "display it within the message" (as an email client does with an embedded image). Setting it lets you control that behavior — though clients ultimately decide how to honor the hint.Chilkat Unicode C Downloads
#include <C_CkEmailW.h>
void ChilkatSample(void)
{
BOOL success;
HCkEmailW email;
success = FALSE;
// Demonstrates the SetAttachmentDisposition method, which sets the Content-Disposition
// value for the attachment at the given zero-based index. The default disposition is
// "attachment".
email = CkEmailW_Create();
CkEmailW_putSubject(email,L"Set attachment disposition");
CkEmailW_AddStringAttachment(email,L"image.txt",L"(pretend inline content)");
// Set the disposition of the first attachment (index 0) to "inline".
success = CkEmailW_SetAttachmentDisposition(email,0,L"inline");
if (success == FALSE) {
wprintf(L"%s\n",CkEmailW_lastErrorText(email));
CkEmailW_Dispose(email);
return true;
}
// The attachment's Content-Disposition is now "inline".
wprintf(L"%s\n",CkEmailW_getMime(email));
CkEmailW_Dispose(email);
}