Ejemplo n.º 1
0
int CMapiMessage::CountAttachments( void)
{
  m_attachNums.Clear();

  LPSPropValue pVal = CMapiApi::GetMapiProperty( m_lpMsg, PR_HASATTACH);
  BOOL has = TRUE;

  if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_BOOLEAN)) {
    has = (pVal->Value.b != 0);
  }
  if (pVal)
    CMapiApi::MAPIFreeBuffer( pVal);

  if (has) {
    // Get the attachment table?
    HRESULT hr;
    LPMAPITABLE pTable = NULL;

    hr = m_lpMsg->GetAttachmentTable( 0, &pTable);
    if (FAILED( hr))
      return( 0);
    m_pAttachTable = pTable;
    IterateAttachTable();
  }

  return m_attachNums.Length();
}
Ejemplo n.º 2
0
// This method must be called AFTER the retrieval of the body,
// since the decision if an attachment is embedded or not is made
// based on the body type and contents
void CMapiMessage::ProcessAttachments()
{
  LPSPropValue pVal = CMapiApi::GetMapiProperty(m_lpMsg, PR_HASATTACH);
  bool hasAttach = true;

  if (pVal) {
    if (PROP_TYPE(pVal->ulPropTag) == PT_BOOLEAN)
      hasAttach = (pVal->Value.b != 0);
    CMapiApi::MAPIFreeBuffer(pVal);
  }

  if (!hasAttach)
    return;

  // Get the attachment table?
  LPMAPITABLE pTable = NULL;
  HRESULT hr = m_lpMsg->GetAttachmentTable(0, &pTable);
  if (FAILED(hr) || !pTable)
    return;
  IterateAttachTable(pTable);
  pTable->Release();
}