Update vmime 0.7.1 to 0.9.1
I am trying to update my vmime implementation from 0.7.1 to 0.9.1.
I am having no luck finding good examples of extracting the attachments from an email... and this is the code below that used to work in 0.7.1:
// NOTE: this->msg is a vmime::message* msg;
// see if the body IS an attachment
const vmime::header& hdr = *this->msg->getHeader();
const vmime::body& bdy = *this->msg->getBody();
bool isAttachment = false;
vmime::defaultParameter* def_param = NULL;
vmime::contentTypeField* ctf = NULL;
// this will get the name field for the particular body part
try
{
ctf = dynamic_cast <vmime::contentTypeField*> (hdr.findField(vmime::fields::CONTENT_TYPE));
def_param = dynamic_cast <vmime::defaultParameter*>(ctf->getParameter("name"));
log_debug2("Content_type->name = [%s]", def_param->getValue().getBuffer().c_str());
}
catch (vmime::exceptions::no_such_field)
{
log_debug1("no Content Type field");
def_param = NULL;
}
try
{
const vmime::contentDispositionField& cdf = dynamic_cast<vmime::contentDispositionField&>
(*hdr.findField(vmime::fields::CONTENT_DISPOSITION));
How should I be doing this in 0.9.1?
Thanks
Joe Johnson
Also I was using this to get the filename of an attachment,
where
const vmime::attachment& attach = *(this->mp)->getAttachmentAt(attach_idx);
this->mp->getAttachmentInfo(&attach)->getFilename().getBuffer();
How is this done in v0.9.1? getAttachmentInfo() is no longer implemented.
Hi!
getAttachmentInfo() is no longer available, instead you should use attach.getName()
As for your first question, what is not working in 0.9.1? (apart from minor changes in function names, and smart pointer usage)
Vincent