Embedded attachments in a Mimefile?

Reply

Join Date: Aug 2007
Posts: 2
Reputation: monsieur_jj is an unknown quantity at this point 
Solved Threads: 0
monsieur_jj monsieur_jj is offline Offline
Newbie Poster

Embedded attachments in a Mimefile?

 
0
  #1
Aug 24th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 2
Reputation: monsieur_jj is an unknown quantity at this point 
Solved Threads: 0
monsieur_jj monsieur_jj is offline Offline
Newbie Poster

Re: Embedded attachments in a Mimefile?

 
0
  #2
Aug 24th, 2007
apologies for the code above
  1. class CExtMimeEmbed : public CMimeFileAttachment
  2. {
  3. public:
  4. CExtMimeEmbed(void)
  5. {}
  6. ~CExtMimeEmbed(void)
  7. {}
  8. protected:
  9. // the encode string ("base64", "quoted-printable", "uuencode")
  10. char *m_pszEncodeString;
  11.  
  12. TCHAR m_szDisplayName[_MAX_FNAME];
  13. // the content type of the attachment
  14. CStringA m_ContentType;
  15.  
  16. virtual inline BOOL MakeMimeHeader(CStringA& header, LPCSTR szBoundary, LPCTSTR szFileName) throw()
  17. {
  18. ATLENSURE(szBoundary != NULL);
  19. ATLASSERT(szFileName != NULL);
  20. ATLASSUME(m_pszEncodeString != NULL);
  21.  
  22. char szBegin[256];
  23. if (*szBoundary)
  24. {
  25. // this is not the only body part
  26. Checked::memcpy_s(szBegin, 256, ATLMIME_SEPARATOR, sizeof(ATLMIME_SEPARATOR));
  27. Checked::memcpy_s(szBegin+6, 250, szBoundary, ATL_MIME_BOUNDARYLEN);
  28. *(szBegin+(ATL_MIME_BOUNDARYLEN+6)) = '\0';
  29. }
  30. else
  31. {
  32. // this is the only body part, so output the MIME header
  33. Checked::memcpy_s(szBegin, 256, ATLMIME_VERSION, sizeof(ATLMIME_VERSION));
  34. }
  35.  
  36. // Get file name with the path stripped out
  37. TCHAR szFile[MAX_PATH+1];
  38. TCHAR szExt[_MAX_EXT+1];
  39. Checked::tsplitpath_s(szFileName, NULL, 0, NULL, 0, szFile, _countof(szFile), szExt, _countof(szExt));
  40. Checked::tcscat_s(szFile, _countof(szFile), szExt);
  41.  
  42. _ATLTRY
  43. {
  44. CT2CAEX<MAX_PATH+1> szFileNameA(szFile);
  45.  
  46. CStringA szDisplayName(szFile);
  47. if (m_szDisplayName[0] != '\0')
  48. {
  49. szDisplayName = CT2CAEX<_MAX_FNAME+1>(m_szDisplayName);
  50. }
  51. /*Content-Type: image/jpeg; name="image003.jpg"
  52. Content-Description: image003.jpg
  53. Content-Disposition: inline; filename="image003.jpg"; size=2313;
  54. creation-date="Wed, 01 Aug 2007 09:51:13 GMT";
  55. modification-date="Wed, 01 Aug 2007 09:51:13 GMT"
  56. Content-ID: <image003.jpg@01C7D464.924CE700>
  57. Content-Transfer-Encoding: base64*/
  58.  
  59. /*Content-Type: image/jpeg;
  60. charset="Windows-1252"
  61. name="image003.jpg"
  62. Content-Transfer-Encoding: base64
  63. Content-Disposition: attachment;
  64. filename="image003.jpg"*/
  65.  
  66. /*header.Format("%s\r\nContent-Type: %s;\"\r\n\tname=\"%s\"\r\n" "\r\nContent-Description: %s;\r\nContent-Disposition: inline;
  67. "\r\n\tfilename=\"%s\"\r\n\r\n" "\r\ncreation-date=\"%s" "\r\nmodification-date=\"%s" "\r\nContent-ID:\%s" "Content-Transfer-Encoding: %s",
  68. szBegin, (LPCSTR) m_ContentType, m_szCharset, (LPCSTR) szDisplayName, m_pszEncodeString, (LPCSTR) szFileNameA); */
  69.  
  70. header.Format("%s\r\nContent-Type: %s;\r\n\tcharset=\"%s\"\r\n\tname=\"%s\"\r\n"
  71. "Content-Transfer-Encoding: %s\r\nContent-Disposition: inline;\r\n\tfilename=\"%s\"\r\n\r\n",
  72. szBegin, (LPCSTR) m_ContentType, m_szCharset, (LPCSTR) szDisplayName, m_pszEncodeString, (LPCSTR) szFileNameA);
  73. return TRUE;
  74. }
  75. _ATLCATCHALL()
  76. {
  77. return FALSE;
  78. }
  79. }
  80.  
  81. };
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC