CDO 1.1 is known to be buggy. If at all possible update the CDO to
1.21.
> I've created the VBA script below to create the
> PR_ATTACH_LONG_FILENAME on a faxed attachment (see my
> previous post on 1/8/2003 "How to refresh MAPI
> properties". All is now well when I run the script as a
> macro on my W2K machine running OL2K. When I export the
> BAS file and load it on a NT4WS machine running OL2K, the
> script runs, the mail closes and opens, but the
> PR_ATTACH_LONG_FILENAME isn't updated. I cannot find an
> error (I put a msgbox for Err.Number and Err.Description
> after the .update without any success). I can see that
> the NT4WS machine has CDO 1.1 and the W2K machine has CDO
> 1.2. Is CDO 1.1 buggy or am I missing something obvious?
> I've searched the newsgroup a dozen different ways but
> cannot find a solution for this.
> Please help. I don't have that much more hair to pull
> out. I'll have to start on my co-irkers next!
> O- Mike Pinter, Sr.
> The Code:
> ==================================================
> Public Const CdoPR_ATTACH_FILENAME = &H3704001E
> Public Const CdoPR_ATTACH_LONG_FILENAME = &H3707001E
> Public Sub TestAttachments()
> Dim objMail As MailItem
> Dim strLongFileName As String
> Dim strFileName As String
> Dim strEntryID As String
> Dim oCDO
> 'On Error Resume Next
> Err.Clear
> Set oCDO = CreateObject("MAPI.Session")
> If Err.Number <> 0 Then
> MsgBox "CDO not available. Error was " &
> Err.Description
> Else
> MsgBox "CDO Version " & oCDO.Version
> Set oCDO = Nothing
> End If
> ' to run this, you might need the CDO references added to
> the PC
> ' start CDO session
> Set objSession = CreateObject("MAPI.Session")
> objSession.Logon "", "", False, False
> ' get the current message
> Set objMail = Application.ActiveInspector.CurrentItem
> ' pass message to CDO
> strEntryID = objMail.EntryID
> strStoreID = objMail.Parent.StoreID
> Set objCDOMsg = objSession.GetMessage(strEntryID,
> strStoreID)
> ' Navigate through all attachments and make Extended MAPI
> If objCDOMsg.Attachments.Count <> 0 Then
> For Each oAttachment In objCDOMsg.Attachments
> 'On Error Resume Next
> 'strLongFileName = oAttachment.Fields.Item
> (CdoPR_ATTACH_LONG_FILENAME)
> 'If strLongFileName = "" Then
> strFileName = oAttachment.Fields.Item
> (CdoPR_ATTACH_FILENAME)
> oAttachment.Fields.Add
> CdoPR_ATTACH_LONG_FILENAME, "Faxed Order.TIF"
> 'End If
> Next
> End If
> ' Very important to update the CDO Object before
> closing!!
> objCDOMsg.Update
> objMail.Close olSave
> strEntryID = objMail.EntryID
> Set objMail = Nothing
> ' get the current message
> Set objMAPIMessage = objSession.GetMessage(strEntryID)
> Set ol = GetObject("", "Outlook.Application")
> Set olns = ol.GetNamespace("MAPI")
> Set objMail = olns.GetItemFromID(objMAPIMessage.ID,
> objMAPIMessage.StoreID)
> objMail.Display False
> End Sub