| | |
Embedded attachments in a Mimefile?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2007
Posts: 2
Reputation:
Solved Threads: 0
I am modifying the class CMimeMessage : public CMimeHeader, i need to modify the
<pre>
virtual inline BOOL MakeMimeHeader(CStringA& header, LPCSTR szBoundary, LPCTSTR szFileName){ATLENSURE(szBoundary != NULL);ATLASSERT(szFileName != NULL);ATLASSUME(m_pszEncodeString != NULL);char szBegin[256];if (*szBoundary){// this is not the only body partChecked::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 headerChecked::memcpy_s(szBegin, 256, ATLMIME_VERSION, sizeof(ATLMIME_VERSION));}// Get file name with the path stripped outTCHAR 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 szFileNameA(szFile);CStringA szDisplayName(szFile);if (m_szDisplayName[0] != '\0'){szDisplayName = CT2CAEX<_MAX_FNAME+1>(m_szDisplayName);}header.Format("%s\r\nContent-Type: %s;\r\n\tcharset=\"%s\"\r\n\tname=\"%s\"\r\n""Content-Transfer-Encoding: %s\r\nContent-Disposition: attachment;\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;}}
</pre>
to have an output:
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
instead of:
Content-Type: image/jpeg;
charset="Windows-1252"
name="image003.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="image003.jpg"
Ok my problem is when i am extracting and converting a .eml file to a new .eml file to convert the tnef i am having an issue getting the embedded attachments. When i get them instead of having them as embedded i just have them as a regular attachment due to the code by atlmime.h
Now my question is how can i get them back as embedded attachments, get their content-disposition and content ID? Thanks
The codes are from atlmime.h
<pre>
virtual inline BOOL MakeMimeHeader(CStringA& header, LPCSTR szBoundary, LPCTSTR szFileName){ATLENSURE(szBoundary != NULL);ATLASSERT(szFileName != NULL);ATLASSUME(m_pszEncodeString != NULL);char szBegin[256];if (*szBoundary){// this is not the only body partChecked::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 headerChecked::memcpy_s(szBegin, 256, ATLMIME_VERSION, sizeof(ATLMIME_VERSION));}// Get file name with the path stripped outTCHAR 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 szFileNameA(szFile);CStringA szDisplayName(szFile);if (m_szDisplayName[0] != '\0'){szDisplayName = CT2CAEX<_MAX_FNAME+1>(m_szDisplayName);}header.Format("%s\r\nContent-Type: %s;\r\n\tcharset=\"%s\"\r\n\tname=\"%s\"\r\n""Content-Transfer-Encoding: %s\r\nContent-Disposition: attachment;\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;}}
</pre>
to have an output:
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
instead of:
Content-Type: image/jpeg;
charset="Windows-1252"
name="image003.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="image003.jpg"
Ok my problem is when i am extracting and converting a .eml file to a new .eml file to convert the tnef i am having an issue getting the embedded attachments. When i get them instead of having them as embedded i just have them as a regular attachment due to the code by atlmime.h
Now my question is how can i get them back as embedded attachments, get their content-disposition and content ID? Thanks
The codes are from atlmime.h
•
•
Join Date: Aug 2007
Posts: 2
Reputation:
Solved Threads: 0
apologies for the code above
C++ Syntax (Toggle Plain Text)
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; } } };
![]() |
Similar Threads
- Sending pic attachments via PHP form (PHP)
- Word 2002 hogs CPU with Visio drawing embedded. (Windows NT / 2000 / XP)
- infected, embedded object. (Viruses, Spyware and other Nasties)
- embedded linux (Getting Started and Choosing a Distro)
- XP embedded (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: Downloading files from web address'
- Next Thread: Help in CRITICAL_SECTION
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





