Backup cemail.vol

Hello everyone!

I need to backup/copy my cemail.vol.....how i can do this I trying to copy my cemail.vol...but i give a "IOException". help me please....



Answer this question

Backup cemail.vol

  • Rich Hoffman

    I don't have the System.StackTrace....um using .NET Compact framework 1.0.....my ex.Message return IOException.


  • him19010

    This is my code:

    FileInfo myFile = new FileInfo(@"\cemail.vol");

    myFile.MoveTo(@"\cemail_bck.vol");

    But i give same IOException.


  • cssjm

    mgaur_MSFT wrote:

    IOException is because of sharing violation. Do the following:

    • Rename cemail.vol to say cemail_bak.vol
    • Restart the phone/ppc, You'll see a new file with name cemail.vol is created
    • Copy the cemail_bak.vol to a new location.
    • Rename the newer cemail.vol to cemail_delete.vol and rename your cemail_bak.vol to cemail.vol.
    • Restart and delete your cemail_delete.vol

    Manav

    It does not allow to rename either. Same IOexception error. What do I do



  • Toseef

    cemail.vol is a system file and can not be deleted. It is used by MAPI for storing the SMS and mail items. The storage format is EDB. More information about CEDB and EDB database is available http://msdn.microsoft.com/library/default.asp url=/library/en-us/wcedata5/html/wce50grfdatabasereference340.asp

    This article http://www.codecomments.com/archive425-2006-5-904897.html has information about a sample source code for mounting and enumerating records in cemail.vol database.

    Closing this topic as answered. Please post your followon questions about the database access to http://forums.microsoft.com/MSDN/ShowForum.aspx ForumID=152&SiteID=1

    Thanks,

    Manav



  • Yeshia

    Nothing to do!! I have killed poutlook.exe process and i have same exception, so i have killed also tmail.exe and pMSNServer.exe...but without success.

    :-(


  • StUdEnT in distress

    Can you please post the stack trace of the exception

    Manav



  • DeltaXXX

    You can't rename cemail.vol, open all database in cemail.vol and read all properties.

    This is my code :

    BOOL BackupMail()

    {

    CEGUID ceguidCemail;

    CEGUID ceguidBackUp;

    //Initialisation

    CREATE_INVALIDGUID(&ceguidCemail);

    CREATE_INVALIDGUID(&ceguidBackUp);

    if(!CeMountDBVolEx(&ceguidCemail, L"cemail.vol", NULL, OPEN_EXISTING))

    {

    DWORD dwErro = GetLastError();

    return FALSE;

    }

    if(!CeMountDBVolEx( &ceguidBackUp, L"cemail_Backup.vol", NULL, CREATE_ALWAYS | EDB_MOUNT_FLAG))

    {

    return FALSE;

    }

    HANDLE hDatabaseEnumHandle = INVALID_HANDLE_VALUE;

    if((hDatabaseEnumHandle = CeFindFirstDatabaseEx(&ceguidCemail, 0)) == INVALID_HANDLE_VALUE)

    {

    return FALSE;

    }

    CEOID ceoidFind = 0;

    while(ceoidFind = CeFindNextDatabaseEx(hDatabaseEnumHandle, NULL))

    {

    HANDLE hSession = CeCreateSession(&ceguidCemail);

    HANDLE hDBOpened = INVALID_HANDLE_VALUE;

    hDBOpened = CeOpenDatabaseInSession(

    hSession,

    &ceguidCemail,

    &ceoidFind,

    NULL,

    NULL,

    CEDB_AUTOINCREMENT,

    NULL);

    if(hDBOpened == INVALID_HANDLE_VALUE)

    {

    DWORD error = GetLastError();

    return FALSE;

    }

    // get informations

    BY_HANDLE_DB_INFORMATION hDBOpenedInfo;

    hDBOpenedInfo.wVersion = BY_HANDLE_DB_INFORMATION_VERSION;

    if(!CeGetDBInformationByHandle(hDBOpened, &hDBOpenedInfo))

    {

    DWORD dwError = GetLastError();

    return FALSE;

    }

    CEOIDINFOEX cdDb;

    CEOID ceoidFindRecorde;

    CeOidGetInfoEx2(&ceguidCemail,ceoidFindRecorde, &cdDb);

    // create a copy

    CEOID ceoidDBaseCopy = 0;

    if(!(ceoidDBaseCopy = CeCreateDatabaseWithProps(

    &ceguidBackUp,

    &hDBOpenedInfo.infDatabase,

    0,

    NULL)))

    {

    DWORD dwErro = GetLastError();

    return FALSE;

    }

    //open the copy

    HANDLE hSession = CeCreateSession(&ceguidBackUp);

    HANDLE hDBaseCopyHandle = INVALID_HANDLE_VALUE;

    hDBaseCopyHandle = CeOpenDatabaseInSession(

    hSession,

    &ceguidBackUp,

    &ceoidDBaseCopy,

    hDBOpenedInfo.infDatabase.szDbaseName,

    NULL,

    CEDB_AUTOINCREMENT,

    NULL);

    if(hDBaseCopyHandle == INVALID_HANDLE_VALUE)

    {

    return FALSE;

    }

    // get informations

    BY_HANDLE_DB_INFORMATION hDBOpenedInfo;

    hDBOpenedInfo.wVersion = BY_HANDLE_DB_INFORMATION_VERSION;

    if(!CeGetDBInformationByHandle(hDBaseCopyHandle, &hDBOpenedInfo))

    {

    DWORD dwError = GetLastError();

    return FALSE;

    }

    DWORD dwCpt = 0;

    CEOID ceoidFindRecord = 0;

    WORD dwPropId = 0;

    CEPROPVAL* Buffer = NULL;

    DWORD dwSizeOfBuffer = 0;

    HANDLE hHeap = NULL;

    hHeap = GetProcessHeap();

    if(hHeap == NULL)

    return FALSE;

    while(ceoidFindRecord = CeReadRecordPropsEx(

    hDBOpened, // Handle of the database

    CEDB_ALLOWREALLOC, // Use LocalAlloc to get the buffer

    &dwPropId, // Number of properties retrieved

    NULL, // NULL means retrieve all properties.

    (LPBYTE*)&Buffer, // Buffer receives property data.

    &dwSizeOfBuffer, // Handle to the heap for allocating the record when

    // CEDB_ALLOWREALLOC is specified

    hHeap)) // A handle to an application-created

    dwCpt++;

    if(GetLastError() != ERROR_NO_MORE_ITEMS)

    return false;

    free(Buffer);

    Buffer = NULL;

    CeSeekDatabaseEx(hDBOpened, CEDB_SEEK_BEGINNING, 0, 0, NULL);

    ceoidFindRecord = 0;

    DWORD dwNumberOfRecordFound = 0;

    BOOL esito;

    while(dwNumberOfRecordFound++ < dwCpt)

    {

    // Find record

    ceoidFindRecord = CeReadRecordPropsEx(

    hDBOpened, // Handle of the database.

    CEDB_ALLOWREALLOC, // Use LocalAlloc to get the buffer.

    &dwPropId, // Number of properties retrieved

    NULL, // NULL means retrieve all properties.

    (LPBYTE*)&Buffer, // Buffer receives property data.

    &dwSizeOfBuffer, // Handle to the heap for allocating the record when

    // CEDB_ALLOWREALLOC is specified.

    hHeap); // A handle to an application-created

    if(!ceoidFindRecord)

    {

    DWORD dwError = GetLastError();

    return FALSE;

    }

    // Add property in backupDB

    CEOID ceoidRecordAdd;

    ceoidRecordAdd = CeWriteRecordProps(

    hDBaseCopyHandle, // Handle to DB

    0, // 0=> add new record

    dwPropId, // propID

    Buffer); // BLOB buffer record

    // buffer

    if(!ceoidRecordAdd)

    {

    DWORD dwError = GetLastError();

    MessageBox(0, L"Error", L"Error", 1);

    return FALSE;

    }else

    {

    //MessageBox(0, L"Ok", L"Ok", 1);

    }

    //free(temp);

    //temp = NULL;

    free(Buffer);

    Buffer = NULL;

    }

    }

    if(!CeFlushDBVol(&ceguidCemail))

    return FALSE;

    if(!CeFlushDBVol(&ceguidBackUp))

    return FALSE;

    if(!CeUnmountDBVol(&ceguidCemail))

    return FALSE;

    if(!CeUnmountDBVol(&ceguidBackUp))

    return FALSE;

    return TRUE;

    }


  • ChandraP

    Although I have not tried this but this should let you achieve your objective.

    1. Use Remote Process viewer that comes with VS installation. Connect to your device/emulator and kill poutlook.exe (Pocket Outlook).

    2. Now you can use Remote File Viewer to rename the file and copy it elsewhere.

    Manav



  • magikalpnoi

    Hi,

    In WM 5.0 you can not rename, delete and etc. '\cemail.vol'. It is placed in distinct storage.


  • Larry Blanton

    Thanks, im starting with this solutions.


  • chakravarthy_b

    IOException is because of sharing violation. Do the following:

    • Rename cemail.vol to say cemail_bak.vol
    • Restart the phone/ppc, You'll see a new file with name cemail.vol is created
    • Copy the cemail_bak.vol to a new location.
    • Rename the newer cemail.vol to cemail_delete.vol and rename your cemail_bak.vol to cemail.vol.
    • Restart and delete your cemail_delete.vol

    Manav



  • Backup cemail.vol