Solved

CDO error 80004005 while attempting to save attachments.

Posted on 2004-09-06
4
1,404 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using YubiKey with REST API application 2 115
splitOdd10 challenge 5 104
mapAB Challlenge 35 143
Adoquery sql  left join does not work 25 89
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

785 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