I use the method AddFileAttachment to add attachments to a CkEmail object.
When the attachment is an mht file, I encountered the next problems:
- the return value is TRUE,
- the method get_NumAttachments() returns 0 (?).
- the method SetAttachmentFilename() returns FALSE. I receive the next error message:
Index out of range: no attachment at index = 0.
- the attachment sent has no name (because the SetAttachmentFilename failed),
- the attachment sent is empty.
Chilkat treats attached messages differently than file attachments. The .mht file extension defaults to a content-type of message/rfc822, so when a .mht file is added, it will appear as an attached message. (You can use the methods/properties dealing with attached messages.)
An alternative is to call AddFileAttachment2 where you can directly specify the content-type:
The "application/octet-stream" is the content type that is used for any unrecognized file extension (.dat for example). This will cause Chilkat to behave correctly, and email clients such as Outlook, Thunderbird, etc. should also treat it as a normal file attachment (i.e. it shouldn’t inline the attachment into your email.)