class CExtMimeEmbed : public CMimeFileAttachment
{
public:
CExtMimeEmbed(void)
{}
~CExtMimeEmbed(void)
{}
protected:
// the encode string ("base64", "quoted-printable", "uuencode")
char *m_pszEncodeString;
TCHAR m_szDisplayName[_MAX_FNAME];
// the content type of the attachment
CStringA m_ContentType;
virtual inline BOOL MakeMimeHeader(CStringA& header, LPCSTR szBoundary, LPCTSTR szFileName) throw()
{
ATLENSURE(szBoundary != NULL);
ATLASSERT(szFileName != NULL);
ATLASSUME(m_pszEncodeString != NULL);
char szBegin[256];
if (*szBoundary)
{
// this is not the only body part
Checked::memcpy_s(szBegin, 256, ATLMIME_SEPARATOR, sizeof(ATLMIME_SEPARATOR));
Checked::memcpy_s(szBegin+6, 250, szBoundary, ATL_MIME_BOUNDARYLEN);
*(szBegin+(ATL_MIME_BOUNDARYLEN+6)) = '\0';
}
else
{
// this is the only body part, so output the MIME header
Checked::memcpy_s(szBegin, 256, ATLMIME_VERSION, sizeof(ATLMIME_VERSION));
}
// Get file name with the path stripped out
TCHAR szFile[MAX_PATH+1];
TCHAR szExt[_MAX_EXT+1];
Checked::tsplitpath_s(szFileName, NULL, 0, NULL, 0, szFile, _countof(szFile), szExt, _countof(szExt));
Checked::tcscat_s(szFile, _countof(szFile), szExt);
_ATLTRY
{
CT2CAEX<MAX_PATH+1> szFileNameA(szFile);
CStringA szDisplayName(szFile);
if (m_szDisplayName[0] != '\0')
{
szDisplayName = CT2CAEX<_MAX_FNAME+1>(m_szDisplayName);
}
/*Content-Type: image/jpeg; name="image003.jpg"
Content-Description: image003.jpg
Content-Disposition: inline; filename="image003.jpg"; size=2313;
creation-date="Wed, 01 Aug 2007 09:51:13 GMT";
modification-date="Wed, 01 Aug 2007 09:51:13 GMT"
Content-ID: <image003.jpg@01C7D464.924CE700>
Content-Transfer-Encoding: base64*/
/*Content-Type: image/jpeg;
charset="Windows-1252"
name="image003.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="image003.jpg"*/
/*header.Format("%s\r\nContent-Type: %s;\"\r\n\tname=\"%s\"\r\n" "\r\nContent-Description: %s;\r\nContent-Disposition: inline;
"\r\n\tfilename=\"%s\"\r\n\r\n" "\r\ncreation-date=\"%s" "\r\nmodification-date=\"%s" "\r\nContent-ID:\%s" "Content-Transfer-Encoding: %s",
szBegin, (LPCSTR) m_ContentType, m_szCharset, (LPCSTR) szDisplayName, m_pszEncodeString, (LPCSTR) szFileNameA); */
header.Format("%s\r\nContent-Type: %s;\r\n\tcharset=\"%s\"\r\n\tname=\"%s\"\r\n"
"Content-Transfer-Encoding: %s\r\nContent-Disposition: inline;\r\n\tfilename=\"%s\"\r\n\r\n",
szBegin, (LPCSTR) m_ContentType, m_szCharset, (LPCSTR) szDisplayName, m_pszEncodeString, (LPCSTR) szFileNameA);
return TRUE;
}
_ATLCATCHALL()
{
return FALSE;
}
}
};