有没有人解析过*.eml文件用的什么方法,谈点经验!!小弟十分着急谢谢

解决方案 »

  1.   

    try this
    #include "mapidefs.h"
    #include "imessage.h"
    #include "MAPIUTIL.H"
    #pragma comment(lib,"mapi32")
    ...
    LPSTORAGE pStorage = NULL;
    HRESULT hr = StgOpenStorage (L"c:\\test.eml", NULL,
                                 STGM_TRANSACTED |
                                 STGM_READWRITE |
                                 STGM_SHARE_EXCLUSIVE,
                                 NULL, 0, &pStorage);
    LPMESSAGE pMessage = NULL;
    LPMALLOC pMalloc = MAPIGetDefaultMalloc();
    hr = OpenIMsgOnIStg (NULL, MAPIAllocateBuffer, MAPIAllocateMore,
                         MAPIFreeBuffer, pMalloc, NULL, pStorage,
                         NULL, 0, 0, &pMessage);
      

  2.   

    然后呢 
    比如说我怎么得到From,To,Subject等信息呢??
      

  3.   

    #import <cdosys.dll> no_namespace raw_interfaces_only
    #import "c:\program files\common files\system\ado\msado15.dll" no_namespace raw_interfaces_only
    #include "cdosysstr.h"
    #include "cdosyserr.h"
    #include <comdef.h>
    ...
    IMessagePtr Load_Message_from_File(_bstr_t path)
    {
          /*
          ** This example shows a common use of the ADO Stream
          ** object with CDO, namely, opening a serialized
          ** message from a file on disk and loading it into
          ** a CDO Message object.
          **/      _StreamPtr  pStm(__uuidof(Stream));
          _variant_t varOptional(DISP_E_PARAMNOTFOUND,VT_ERROR);
          try {
      pStm->Open(
            //    pStm->raw_Open(
                                varOptional, 
                                adModeUnknown,   
                                adOpenStreamUnspecified,
                                NULL,
                                NULL);
                pStm->LoadFromFile(path);
          }
          catch(_com_error e)
          {
                throw e;
          }      IMessagePtr iMsg(__uuidof(Message));
          IDataSourcePtr iDsrc;
          iDsrc = iMsg;      try {
                iDsrc->OpenObject(pStm,_bstr_t("_Stream"));
          }
          catch(_com_error e)
          {
                throw e;
          }
          return iMsg;
    }
    void GetFrom()
    {
    IMessagePtr imsgptr=Load_Message_from_File("c:\\test.eml");
    BSTR bsfrom;
    imsgptr->get_From(&bsfrom);
    _bstr_t bfrom(bsfrom); AfxMessageBox(bfrom);
    }
      

  4.   

    正文段通常是类似html格式的文档,怎么处理呢?
      

  5.   

    look up HRESULT IMessage::get_BodyPart(IBodyPart** pVal);
      

  6.   

    IBodyPart Interface
    The IBodyPart interface defines a set of methods and properties used to manipulate message body parts. 
      

  7.   

    为什么我的msdn上面找不到从文件里得到信息的例子和说明(都是怎样存储成文件的)你的就有呢?
      

  8.   

    which version do you use? mine is 2001 Oct.
    not all codes are found in MSDN, some of them is written by myself:)
      

  9.   

    不行,我在98下这些文件都import不进来!