Solved

CDO error 80004005 while attempting to save attachments.

Posted on 2004-09-06
4
1,399 Views
Last Modified: 2008-01-09
I've created an application that comprises a mail exchange between the peripheral PC and the central software.
In most environments this works very well, but on some (not all) PC with WindowsXP and Outlook 2003 i get the error in the title.
The error description is not very helpful and I'm trying to guess if it is a security restriction of the outlook settings or something else is going wrong (e.g. in the destination directory).
How can I determine what's going wrong?
How can I check if there are such restrictions and remove them?
I enclose the code below
Looking at the log file, I determined the error occurs in the line
      objAttach.WriteToFile baseDir$ & "\AttDir" & CStr(maxCode%) & "\" & objAttach.Name


Public Function CheckMail(ByVal baseDir$, ByVal lblNotify As Label)
Dim objSession As Object
Dim objInbox As Object
Dim objMessage As Object
Dim objMsgList As Object
Dim objRecipient As Object
Dim objAttList As Object
Dim objAttach As Object
Dim codeList$(20)
Dim actHidden$
Dim dCount%, mCount%
Dim attDir$
Dim minFree%, maxCode%
Dim actDir As clsAttachDir
 For dCount% = 0 To 20
  attDir$ = baseDir$ & "\Att" & CStr(dCount%)
 Next dCount%
 Set objSession = CreateObject("MAPI.Session")
#If LOGGING Then
 WriteLog "Check Mail: Connecting profile"
#End If
 lblNotify.Caption = "Connecting profile: " & GetINIMailProfile$
 DoEvents
 objSession.Logon profileName:=GetINIMailProfile$
#If LOGGING Then
 WriteLog "Check Mail: Accessing Inbox"
#End If
 Set objInbox = objSession.Inbox
#If LOGGING Then
 WriteLog "Check Mail: Getting message list"
#End If
 Set objMsgList = objInbox.Messages
#If LOGGING Then
 WriteLog "Check Mail: Getting the first message"
#End If
 Set objMessage = objMsgList.GetFirst
 Do While Not objMessage Is Nothing
  lblNotify.Caption = "Reading message " & CStr(mCount%)
  DoEvents
#If LOGGING Then
  WriteLog "Check Mail: Getting the subject"
#End If
  If objMessage.subject Like "CAPRI *" Then
   actHidden$ = Mid$(objMessage.subject, 7)
   If Len(actHidden$) = 17 And iIsInt(Mid$(actHidden$, 1, 4)) And iIsInt(Mid$(actHidden$, 5, 4)) _
   And iIsInt(Mid$(actHidden$, 9, 4)) Then
    If CInt(Mid$(actHidden$, 5, 2)) < 13 And CInt(Mid$(actHidden$, 7, 2)) < 32 Then
#If LOGGING Then
     WriteLog "Check Mail: Getting the attachment list for message " & actHidden$
#End If
     Set objAttList = objMessage.Attachments
#If LOGGING Then
     WriteLog "Check Mail: Getting the attachment list count"
#End If
     If objAttList.Count > 0 Then
#If LOGGING Then
      WriteLog "Check Mail: Getting the fist attachment"
#End If
      Set objAttach = objAttList.Item(1)
      maxCode% = -1
      minFree% = 21
      For dCount% = 0 To 20
       Set actDir = New clsAttachDir
       actDir.Init baseDir$ & "\AttDir" & CStr(dCount%)
       If actDir.TransfCode = Mid$(actHidden$, 13, 5) Then
        maxCode% = dCount%
       ElseIf codeList$(dCount%) = "" And minFree% = 21 Then
        minFree% = dCount%
       End If
      Next dCount%
      If maxCode% = -1 Then
       codeList$(minFree%) = Mid$(actHidden$, 13, 5)
       maxCode% = minFree%
      End If
      actDir.Init baseDir$ & "\AttDir" & CStr(maxCode%)
#If LOGGING Then
      WriteLog "Check Mail: Writing attachment to file"
#End If
      objAttach.WriteToFile baseDir$ & "\AttDir" & CStr(maxCode%) & "\" & objAttach.Name
      actDir.AddPart CInt(Mid$(actHidden$, 9, 2)), CInt(Mid$(actHidden$, 11, 2)), objAttach.Name, Mid$(actHidden$, 13, 5)
#If LOGGING Then
      WriteLog "Check Mail: deleting message"
#End If
      objMessage.Delete
     End If
    End If
   End If
  End If
#If LOGGING Then
  WriteLog "Check Mail: Getting next message"
#End If
  Set objMessage = objMsgList.GetNext
 Loop
 
 objSession.LOGOFF
 UpdateMailCheck
 lblNotify.Caption = "Processing mail attachments."
 DoEvents
 ProcessAttachments baseDir$, lblNotify
 If Not certTypeOk Then
  LoadCertTypes
 End If
 If Not flagsOk Then
  LoadFlags
 End If
 If Not authoritiesOk Then
  LoadAuthorities
 End If
 If Not unitsOk Then
  LoadUnits
 End If
' If Not ownersOk Then
'  LoadOwners
' End If
 If sysTabsChanged Or permCodesChanged Then
  If Not CENTRAL_VERSION Then
   LoadOUTypes
  End If
 End If
End Function

Thanks

Gabriele Meloncelli
0
Comment
Question by:GMELONCELLI
  • 2
4 Comments
 
LVL 22

Expert Comment

by:cookre
ID: 11991708
0
 
LVL 4

Accepted Solution

by:
Jigit earned 500 total points
ID: 11991779
Hi,
you are right with your conclusions. There are definitely some security restrictions applied in Office XP SP2 and Office 2003. When your program tries to access some mail item properties (for example, subject) Office pops up a confirmation message. This happens only when the program runs in context of an interactive user. If your program runs with a non interactive account (for example MACHINE_ASPNET ) it just stops running without displaying anything. It's a well known issue and Microsoft published a lot of articles about this issues. I'll try to find some and publish here.
Fortunately, there is a solution -  program called Outlook Redemption: http://www.dimastr.com/redemption/
It enables bypassing security limitations of Office. It really works great and it's the only known solution for this problem.

HTH,
Jigit
0
 
LVL 10

Expert Comment

by:Kavar
ID: 11997347
The security limitations can be by passed if you set up your exchange environment to "trust" the executable running this code.

to set up the Outlook Security Settings Folder follow the steps outlined in:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;263297

I believe that this is your best method of moving forward, because it requires no client configuration and as more and more machines move to outlook 2000+ you will get more and more of these problems.
0
 
LVL 4

Expert Comment

by:Jigit
ID: 12017493
Thank you for accepting my answer - it helped me to become an Expert!

Here are some useful links about this issue:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_ol2003_ta/html/odc_OLWhatsNew2k3.asp
http://www.microeye.com/resources/res_tech_vsnet.htm

Could you please fill a feedback? (just click "feedback" link near the Accepted Answer)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now