vmime
vmime copied to clipboard
Hot to get CC email addresses from vmime 0.9
I am having trouble with this code I am trying to get working in version 0.9 (Updating from version 0.7):
It crashed at getAddressCount()....
Where is a simple example of getting the CC addresses? I cannot find it.
vmime::addressList cc_list = *this->msg->getHeader()->findField(vmime::fields::CC)->getValue().dynamicCast <vmime::addressList>();
vmime::ref <vmime::mailbox> cc_mbx;
this->cc = "";
for(ii=0;ii<cc_list.getAddressCount();ii++)
{
cc_mbx = cc_list.getAddressAt(ii).dynamicCast <vmime::mailbox>();
std::ostringstream tmp_cn_component;
vmime::utility::outputStreamAdapter tmp_cnAdapter_component(tmp_cn_component);
{
cc_mbx->generate(tmp_cnAdapter_component);
log_debug2("tmp_cnAdapter_component=[%s]", tmp_cn_component.str().c_str());
if(tmp_cn_component.str().find("disclosed") != string::npos && tmp_cn_component.str().find("cipient") != string::npos)
{
has_email_flag = 0;
}
else if(tmp_cn_component.str().find("@") == string::npos)
{
has_email_flag = 0;
}
else
{
has_email_flag = 1; // otherwise there must be an email, so we can get it
}
}
std::ostringstream cn_component;
vmime::utility::outputStreamAdapter cnAdapter_component(cn_component);
cc_mbx->getName().generate(cnAdapter_component, vmime::lineLengthLimits::infinite, 0, NULL );
log_debug2("CC Name = [%s]", cn_component.str().c_str());
if(has_email_flag == 0)
{
this->to = cn_component.str();
}
else
{
if(this->cc.length() > 0)
{
this->cc += ", ";
}
if(cn_component.str().length() < 1)
{
try
{
this->cc += cc_mbx->getEmail();