Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | sort of works. when export, transport headers become part of message content, so i might need to see if i can stick them where they need to go in the vmime message. also, datetime is date wrong and time right. |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | main | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
7a79f980e4c238a07ad859d382582966 |
| User & Date: | pasquale 2025-03-31 17:37:48 |
Context
|
2025-04-21
| ||
| 12:29 | working on laying groundwork for more detailed export/import features. check-in: caaf33b2c7 user: pasquale tags: main, trunk | |
|
2025-03-31
| ||
| 17:37 | sort of works. when export, transport headers become part of message content, so i might need to see if i can stick them where they need to go in the vmime message. also, datetime is date wrong and time right. check-in: 7a79f980e4 user: pasquale tags: main, trunk | |
| 15:00 | generating report and exporting msg attachments works. check-in: bdbfc78b60 user: pasquale tags: main, trunk | |
Changes
Changes to wombatmail.cpp.
| ︙ | ︙ | |||
1896 1897 1898 1899 1900 1901 1902 |
std::string curmsg = std::string(mbuf);
mboxout << curmsg;
mailboxfile.close();
delete[] mbuf;
}
else if(mailboxtype == 0x03) // MSG
{
| | | | | > | < | | > | | | | | | | | | < | > > > > > < | 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 |
std::string curmsg = std::string(mbuf);
mboxout << curmsg;
mailboxfile.close();
delete[] mbuf;
}
else if(mailboxtype == 0x03) // MSG
{
// MOST WORKS, DATE ISN'T RIGHT, PULLING JAN 1 2025 WHICH IS WRONG... BUT THE TIME IS RIGHT...
// ALSO, TRANSPORT HEADERS ARE NOW PART OF CONTENT, WHICH THEY SHOULDN'T BE, SO I MAY HAVE TO
// SEE IF I CAN ADD THEM TO THE VMIME MESSAGE HEADER INDIVIDUALLY
std::time_t ttime = std::time(nullptr);
char tstr[100];
std::strftime(tstr, sizeof(tstr), "%a %b %d %H:%M:%S %Y", std::localtime(&ttime));
std::string fromline = "\n\nFrom - " + std::string(tstr) + "\n";
mboxout << fromline;
//std::cout << "START EXPORT" << std::endl;
std::string mbpath = mhparts.at(0);
OutlookMessage* emsg = new OutlookMessage(&mbpath);
try
{
vmime::messageBuilder mb;
mb.setSubject(vmime::text(emsg->Subject()));
mb.setExpeditor(vmime::mailbox(emsg->SenderAddress()));
std::istringstream mhstream(emsg->Receivers());
std::string curto;
while(getline(mhstream, curto, ';'))
mb.getRecipients().appendAddress(vmime::make_shared<vmime::mailbox>(curto));
mb.getCopyRecipients().appendAddress(vmime::make_shared<vmime::mailbox>(emsg->CarbonCopy()));
mb.getBlindCopyRecipients().appendAddress(vmime::make_shared<vmime::mailbox>(emsg->BlindCarbonCopy()));
mb.getTextPart()->setCharset(vmime::charsets::ISO8859_15);
//std::string msgcontent = emsg->Body() + "\n" + emsg->TransportHeader() + "\n";
std::string msgcontent = emsg->TransportHeader() + "\n" + emsg->Body() + "\n";
mb.getTextPart()->setText(vmime::make_shared<vmime::stringContentHandler>(msgcontent));
uint32_t attachcount = 0;
emsg->AttachmentCount(&attachcount);
std::vector<AttachmentInfo> msgattach;
emsg->GetMsgAttachments(&msgattach, attachcount);
std::string attachmentname = "";
for(int k=0; k < msgattach.size(); k++)
{
if(!msgattach.at(k).longname.empty())
attachmentname = msgattach.at(k).longname;
else if(!msgattach.at(k).name.empty())
attachmentname = msgattach.at(k).name;
else if(!msgattach.at(k).contentid.empty())
attachmentname = msgattach.at(k).contentid;
std::vector<uint8_t> attachmentcontent;
emsg->GetAttachmentContent(&attachmentcontent, msgattach.at(k).entryname);
std::string attachmentcontentstring(attachmentcontent.begin(), attachmentcontent.end());
uint64_t bufsize = 1024;
if(attachmentcontentstring.size() < 1024)
bufsize = attachmentcontentstring.size();
uint8_t* sigbuf = new uint8_t[bufsize+1];
sigbuf[bufsize] = 0;
magic_t magical;
const char* catsig;
magical = magic_open(MAGIC_MIME_TYPE);
magic_load(magical, NULL);
catsig = magic_buffer(magical, sigbuf, bufsize);
std::string catsigstr(catsig);
magic_close(magical);
//std::cout << k+1 << " " << attachmentname << ": " << catsigstr << std::endl;
vmime::shared_ptr<vmime::stringContentHandler> achandler = vmime::make_shared<vmime::stringContentHandler>(attachmentcontentstring);
vmime::shared_ptr<vmime::fileAttachment> curatt = vmime::make_shared<vmime::fileAttachment>(achandler, vmime::word(attachmentname), vmime::mediaType(catsigstr));
curatt->getFileInfo().setFilename(attachmentname);
mb.appendAttachment(curatt);
}
vmime::shared_ptr<vmime::message>curmsg = mb.construct();
vmime::shared_ptr<vmime::header> hdr = curmsg->getHeader();
if(hdr->hasField(vmime::fields::DATE))
{
vmime::shared_ptr<vmime::headerField> curdatehdr = hdr->getField(vmime::fields::DATE);
hdr->removeField(curdatehdr);
}
vmime::shared_ptr<vmime::headerFieldFactory> hffactory = vmime::headerFieldFactory::getInstance();
vmime::shared_ptr<vmime::headerField> datefield = hffactory->create(vmime::fields::DATE);
datefield->setValue(vmime::datetime(emsg->Date()));
hdr->appendField(datefield);
// EXPORT MSG FILE TO MBOXOUT
vmime::utility::outputStreamAdapter out(mboxout);
curmsg->generate(out);
}
catch(vmime::exception& e)
{
std::cerr << "vmime::exception: " << e.what() << std::endl;
}
catch(std::exception& e)
{
std::cerr << "std::exception: " << e.what() << std::endl;
}
}
else if(mailboxtype == 0x04) // EML
{
// EML TEST IS A VALID MBOX, FROM|DATE|SUBJ ARE CORRECT, BUT MISSING EMAIL CONTENTS (BODY|HEADERS).
// GENERATE FROM LINE
std::time_t ttime = std::time(nullptr);
char tstr[100];
|
| ︙ | ︙ |