You might try at MAPI list (CDO)

http://peach.ease.lsoft.com/archives/mapi-l.html 


-----Original Message-----
From: Rick Crawford [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 30, 2001 8:01 PM
To: Exchange Discussions
Subject: Downloading attachment using CDO causes
MAPI_E_NOT_INITIALIZED(80040605)


Hello everyone,

I have an email app that allows a user to download attachments.  I am
running into a problem that after the attachment completes a download, the
CDOSession object throws a [MAPI_E_NOT_INITIALIZED(80040605)]]  error.
Eventually the CDOSession will come back to life and allow me to access
components again.  Anyone have simular experiences?  

Machine has CDO 1.21, CDOSession is created, but it will not let me do
anything for the user.  Strange thing is I can logoff and login as another
user and get functionality back. But, when I try to log back in as the user
that downloaded the attachment, I still get the
[MAPI_E_NOT_INITIALIZED(80040605)]]  error.  Even stranger is the fact that
the user eventually comes back to life...
-rick 
([EMAIL PROTECTED])

Here is the code that performs the download:
Sub DownloadAttachment(ByVal strPath, ByVal strFileName)
        'Get files to download to user's computer
        Dim oActiveFile
        Set oActiveFile = Server.CreateObject("ActiveFile.File")
        
        oActiveFile.Name = strPath & "\" & strFileName 
        Response.Clear
        Response.AddHeader "Content-Disposition", "inline; filename=" &
strFileName
        oActiveFile.Download "application/octet-stream",,false,true
        
        'Clear Memory
        set oActiveFile = nothing
End Sub

Dim strMessageId
Dim lngAttachmentID


'Get Message and attachment ID
strMessageId    = cstr(Request.QueryString("ID"))
lngAttachmentID = clng(Request.QueryString("Item"))

'We do not want to cache files if the temp directory doesn't exist      
if Application("strAttachments") then
        'Create the temp directory
        Dim strPath
        strPath = GetDirectory(strExchangeServer, strMailbox,
lngRandomNumber)
        'Get the message that has the attachments
        Try()
                Dim oMessage
                set oMessage =
Session("CDOSession").GetMessage(strMessageId)
                'Get the attachments for the message
                Dim oAttachments
                set oAttachments = oMessage.Attachments
        
                'Get the attachment
                Dim oAttachment
                set oAttachment = oAttachments.Item(lngAttachmentID)
        
                dim strFileName
                strFileName = oAttachment.Name
                'Write the attachment to the cache
                oAttachment.WriteToFile(strPath & "\" & strFileName)
        if CatchAll then
                ReportError oLocal.GetString(414) 'Unable to download
attachment.
        end if
        
        'Change add one more parameter for strTempID
        call DownloadAttachment(strPath, strFileName)
        
        'cleanup and delete the temp folder
        dim oFileSystemObject
        set oFileSystemObject =
Server.CreateObject("Scripting.FileSystemObject")
        call
oFileSystemObject.DeleteFolder(Application("strCachingDirectory") & "\" &
strExchangeName & "\" & strMailbox, true)
        Set oFileSystemObject = nothing
end if
_________________________________________________________________
List posting FAQ:       http://www.swinc.com/resource/exch_faq.htm
Archives:               http://www.swynk.com/sitesearch/search.asp
To unsubscribe:         mailto:[EMAIL PROTECTED]
Exchange List admin:    [EMAIL PROTECTED]

_________________________________________________________________
List posting FAQ:       http://www.swinc.com/resource/exch_faq.htm
Archives:               http://www.swynk.com/sitesearch/search.asp
To unsubscribe:         mailto:[EMAIL PROTECTED]
Exchange List admin:    [EMAIL PROTECTED]

Reply via email to