CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Memory Error

  1. #1
    Join Date
    Feb 2002
    Posts
    40

    Memory Error

    I'm executing a program that reads achived email messages from a pst file using outlook and writes to local folder.
    The programme works fine with the pst file sizes below 10MB. It gives me this error"out of memory or system resources" and terminates at that point, even though the machine has 4 gig memory.
    T
    his programe opens outlook application to read the pst file.

    Could anyone explai me how and when it utilises the memory, and what memory(buffer/RAM/VM)it uses to execute this application.

    Thanks in advance.




  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Memory Error

    >a program that reads achived email messages from a pst file using outlook and
    writes to local folder

    As you have a lot of ram, it seems strange you get the out of memory message.
    It may be due to the way you use outlook.
    Better post code about how you read the pst file using outlook, to let Codeguru
    people try to find out the matter (if we could...!).

    Have a nice day,

    Cesare Imperiali


    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Feb 2002
    Posts
    40

    Re: Memory Error

    Thank you

    Here is how my program is coded.

    Declarations
    Private mOutlook As Outlook.Application
    Private mNameSpace As Outlook.NameSpace
    Start process
    Dim rtFolders As Outlook.Folders
    Dim rtFolder As Outlook.MAPIFolder
    For I = 1 to numberofpstfiles
    mNameSpace.AddStore pstFile$
    Set rtFolders = mNameSpace.Folders
    Set rtFolder = rtFolders(2)
    Functioncall1 Path$, rtFolder
    mNameSpace.RemoveStore rtFolder
    Next I
    Exit
    End process
    On Error Resume Next
    Set mNameSpace = Nothing
    mOutlook.Quit
    Set mOutlook = Nothing
    Set scrFileSys = Nothing
    mDatabase.Close
    Set mDatabase = Nothing

    Functioncall1 (ByVal curPath$, rtFolder As Outlook.MAPIFolder)
    Dim tmpItms As Outlook.Items
    Dim tmpItm As Object
    Dim tmpFlds As Outlook.Folders
    Dim tmpFld As Outlook.MAPIFolder

    Set tmpItms = rtFolder.Items
    For i& = 1 To tmpItms.count
    Set tmpItm = tmpItms.Item(i&)
    If rtFolder.DefaultItemType = olMailItem Then
    Functioncall2 curPath$, mMsgID&, tmpItm, rtFolder
    Else
    tmpItm.SaveAs itemName$
    End If
    Set tmpItm = Nothing
    Next i&

    Set tmpFlds = rtFolder.Folders

    For i& = 1 To tmpFlds.count
    Set tmpFld = tmpFlds(i&)
    tmpPath$ = tmpFld.Name
    tmpPath$ = GetValidFolder$(tmpPath$)
    tmpPath$ = curPath$ & tmpPath$
    MkDir tmpPath$

    Functioncall1 tmpPath$, tmpFld
    Next i&

    Set tmpItms = Nothing
    Set tmpItm = Nothing
    Set tmpFlds = Nothing
    Set tmpFld = Nothing

    End Functioncall1

    Functioncall2 (ByVal curPath$, ByVal msgID&, mailItm As Object, rtFolder As Outtlook.MAPIFolder)
    Dim tmpAttchs As Outlook.Attachments
    Dim tmpAttch As Object
    Dim editorType%

    editorType% = mailItm.GetInspector.editorType
    itemName$ = curPath$ & itemName$


    If editorType% = 0 Then
    itemName$ = itemName$ & "_000" & ".TXT"
    savedmsgname$ = savedmsgname$ & "_000" & ".TXT"
    mailItm.SaveAs itemName$


    ElseIf editorType% = olEditorHTML Then
    itemName$ = itemName$ & "_000.HTML"
    savedmsgname$ = savedmsgname$ & "_000.HTML"
    mailItm.SaveAs itemName$, olHTML

    ElseIf editorType% = olEditorRTF Or _
    editorType% = olEditorWord Then
    itemName$ = itemName$ & "_000.RTF"
    savedmsgname$ = savedmsgname$ & "_000.RTF"

    mailItm.SaveAs itemName$, olRTF
    Else
    itemName$ = itemName$ & "_000.TXT"
    savedmsgname$ = savedmsgname$ & "_000.TXT"

    mailItm.SaveAs itemName$, olTXT

    Set tmpAttchs = mailItm.Attachments
    ''''''''''''''if the message has any attachment then every attachment is processed.
    For i& = 1 To tmpAttchs.count
    Set tmpAttch = tmpAttchs.Item(i&)
    If tmpAttch.Type = olEmbeddeditem Then
    Functioncall3 curPath$ & itemHoldName$, jj&, tmpAttch, rtFolder, myrecd, savedmsgname$, itemName$
    ElseIf tmpAttch.Type = olOLE Then
    'MsgBox "Can not print.."
    Else
    tmpAttch.SaveAsFile itemAttachName$
    End If
    Next i&
    Set mailItm = Nothing
    Set myrecd = Nothing
    Set tmpAttchs = Nothing
    Set tmpAttch = Nothing

    End Functioncall2
    Functioncall3 (ByVal curPath$, ByVal msgID&, mailItm As Object, rtFolder As Outlook.MAPIFolder, murecordset As Recordset, parentname$, parentpath$)
    Dim tmpAttchs As Outlook.Attachments
    Dim tmpAttch As Object
    Dim tmpItm As Object

    Set tmpItm = mOutlook.CreateItemFromTemplate(itemName$, rtFolder)
    Set tmpAttchs = tmpItm.Attachments
    For i& = 1 To tmpAttchs.count
    Set tmpAttch = tmpAttchs.Item(i&)
    If tmpAttch.Type = olEmbeddeditem Then
    Functioncall3 curPath$, j&, tmpAttch, rtFolder, murecordset, parentname$, parentpath
    ElseIf tmpAttch.Type = olOLE Then
    'MsgBox "Can not print.."
    Else
    tmpAttch.SaveAsFile itemAttachName$
    End If
    Next i&
    Set tmpAttchs = Nothing
    Set tmpAttch = Nothing
    Set tmpItm = Nothing
    Set mailItm = Nothing


    End Functioncall3



    Thanks in advance.


  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Sorry

    Cannot find an easy solution, sorry.

    Cesare Imperiali

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured