This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal


Jan 26, 2016, 3:51 PM
13 Posts

Problems with saving all attachments with Lotusscript

  • Category: Notes Client
  • Platform: Windows
  • Release: 9.0.1
  • Role: Developer
  • Tags: attachments,save,detach,lotusscript
  • Replies: 2

I'm trying to save all attachments from a rich text field in Notes to the disk. Here's my code:

Function varSaveAttachments(docBody As NotesDocument, strPath As String) As Variant
    On Error GoTo ERRORHANDLER
    Dim varRtItem As Variant
    Dim varFilename As Variant
    Dim intCounter As Integer
    Dim strFileName As String

    strPath = Replace(strPath, "/", "_")
    Set varRtItem = docBody.Getfirstitem("Body")
    
    If Not varRtItem Is Nothing Then
        
        If varRtItem.Type = RICHTEXT Then
            
            If Not IsEmpty(varRtItem.EmbeddedObjects) then
                
            ForAll o In varRtItem.EmbeddedObjects
                
                If o.Type = EMBED_ATTACHMENT Then
                    varFileName = Evaluate("@AttachmentNames", docBody)
            
                    For intCounter = 0 To UBound(varFileName)
                        strFileName = varFileName(intCounter)
                        strFileName = Replace(strFileName, "/", "_")
                        Call o.ExtractFile(strPath & "\" & strFileName)
                    Next
                    
                End If
                
            End ForAll
            End If    
        End If                
            
    End If

 

At first this seems to work just fine. Every file in the rich text field is saved to disk, with the correct name.

However, when I open each file, they all contain the same contents as the very first file that is detached.

So if there are ten files in the rich text field, the first attachment is detached 10 times, but are given the the name of the 9 other attachments.

Anyone got any ideas?

Jan 26, 2016, 8:38 PM
82 Posts
this might help ...
Dim rtitem
Set rtitem = doc.GetFirstItem( "Body" )
If ( rtitem.Type = RICHTEXT ) Then
        ForAll o In rtitem.EmbeddedObjects
                If ( o.Type = EMBED_ATTACHMENT ) Then
                        Call o.ExtractFile ( |c:\attachments\| & o.name )
                End If
        End ForAll
End If

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal