// add a binary file attachment\r
else if((*i)->GetName()!="" && (*i)->GetLength()>0 && (*i)->GetContent())\r
{\r
+ std::string contenttype="";\r
std::vector<unsigned char> data((*i)->GetContent(),(*i)->GetContent()+(*i)->GetContentLength());\r
- m_fileattachments.push_back(fileattachment((*i)->GetName(),data));\r
+ if((*i)->GetContentType())\r
+ {\r
+ contenttype=(*i)->GetContentType();\r
+ // find first ; tab cr or lf and erase it and everything after it\r
+ std::string::size_type endpos=contenttype.find_first_of(";\t\r\n ");\r
+ if(endpos!=std::string::npos)\r
+ {\r
+ contenttype.erase(endpos);\r
+ }\r
+ }\r
+ m_fileattachments.push_back(fileattachment((*i)->GetName(),contenttype,data));\r
}\r
}\r
\r
st.Step();\r
\r
// insert file attachments into database\r
- st=m_db->Prepare("INSERT INTO tblFileInserts(MessageUUID,FileName,Size,Data) VALUES(?,?,?,?);");\r
+ st=m_db->Prepare("INSERT INTO tblFileInserts(MessageUUID,FileName,Size,MimeType,Data) VALUES(?,?,?,?,?);");\r
for(std::vector<fileattachment>::iterator i=m_fileattachments.begin(); i!=m_fileattachments.end(); i++)\r
{\r
st.Bind(0,m_messageuuid);\r
st.Bind(1,(*i).m_filename);\r
st.Bind(2,(long)(*i).m_data.size());\r
- st.Bind(3,&((*i).m_data[0]),(*i).m_data.size());\r
+ st.Bind(3,(*i).m_mimetype);\r
+ st.Bind(4,&((*i).m_data[0]),(*i).m_data.size());\r
st.Step();\r
st.Reset();\r
}\r