vmime icon indicating copy to clipboard operation
vmime copied to clipboard

Update vmime 0.7.1 to 0.9.1

Open jjohnson-airlink opened this issue 12 years ago • 2 comments

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

jjohnson-airlink avatar Nov 18 '13 22:11 jjohnson-airlink

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.

jjohnson-airlink avatar Nov 18 '13 23:11 jjohnson-airlink

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

vincent-richard avatar Dec 29 '13 09:12 vincent-richard