bellow is sample code
It reads mails from mailstore and write into temporary file and compare with original file.
problem is : header is present in email files in mailstore but when we read mails from imapstore then it does not read headers so mail comparison fails.
Platform is Rhel6
Vmime rpm is libvmime-0.9.2-0.1.20110626svn.el6.x86_64
sample code :
bool testStoreAttachmentMail::validateOriginalMailStoredToAttachmentMaster(string& szWorkingCopy,AttachmentMailAccessBean& oAttachmentMailAccessBean)
{
// create the imap store connection to the attachment master user
// get the first mail to the attachment store user i.e. last mail added to the user
// compare the mail retrieved and the mail given for the test case
bool bValid = false;
try
{
// connect to the store
vmime::ref <vmime::net::session> sess = vmime::create <vmime::net::session>();
stringszStoreUrl="imap://";szStoreUrl.append(oAttachmentMailAccessBean.getAttachmentMasterUser());szStoreUrl.append(":");szStoreUrl.append(oAttachmentMailAccessBean.getAttachmentMasterPassword());szStoreUrl.append("@");szStoreUrl.append(oAttachmentMailAccessBean.getAttachmentMasterMailStoreIP());vmime::utility::urlstoreURL(szStoreUrl);vmime::ref<vmime::net::store>store=sess->getStore(storeURL);store->connect();// Open the INBOX of the attachment master uservmime::ref<vmime::net::folder>folder=store->getDefaultFolder();folder->open(vmime::net::folder::MODE_READ_WRITE);intiMessageCount=folder->getMessageCount();// get the latest mail stored in the attachment master's mailstorevmime::ref<vmime::net::message>msg=folder->getMessage(iMessageCount);ofstreammyout;stringszFilename=szWorkingCopy+"_retrieved_mail";try{myout.open(szFilename.c_str(),ios::out);if(myout.is_open()){if(m_oLogger->isDebugEnabled()){DEBUG(m_oLogger,"[StoreAttachmentMail(store)] opened File name: "+szFilename);}}else{ERROR(m_oLogger,"[StoreAttachmentMail(store)] could not open File name: "+szFilename);}}catch(std::exception&e){ERROR(m_oLogger,"[StoreAttachmentMail(store)] Exception while storing the attachment file : "+(string)e.what());}// Here, extract() will actually download message data from the servervmime::utility::outputStreamAdapterout(myout);msg->extract(out);myout.flush();myout.close();// compare both the files to validate that same mail has been copiedbValid=cmpFiles(szWorkingCopy,szFilename);if((remove(szFilename.c_str()))==-1){WARN(m_oLogger,"[testStoreAttachmentMail] - <Error while deleting message file, it may not be present "+szFilename);}}catch(stringerror){ERROR(m_oLogger,"[StoreAttachmentMail(store)] Exception while storing the attachment file : "+(string)error);}returnbValid;
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
bellow is sample code
It reads mails from mailstore and write into temporary file and compare with original file.
problem is : header is present in email files in mailstore but when we read mails from imapstore then it does not read headers so mail comparison fails.
Platform is Rhel6
Vmime rpm is libvmime-0.9.2-0.1.20110626svn.el6.x86_64
sample code :
bool testStoreAttachmentMail::validateOriginalMailStoredToAttachmentMaster(string& szWorkingCopy,AttachmentMailAccessBean& oAttachmentMailAccessBean)
{
// create the imap store connection to the attachment master user
// get the first mail to the attachment store user i.e. last mail added to the user
// compare the mail retrieved and the mail given for the test case
bool bValid = false;
try
{
// connect to the store
vmime::ref <vmime::net::session> sess = vmime::create <vmime::net::session>();
}
Hi!
As far as I remember, it may be a bug in extract() function. I can only advise you to use a newer version of VMime.
Unfortunately, there is not recently released package, but you can get the latest sources from the GitHub repository: https://github.com/kisli/vmime
Vincent
ok, thanks for help Richard.