1

何年も前に誰かが共有したエージェントがあり、添付ファイルを取得してハード ドライブに保存し、メールから削除します。メールをしばらく保管するために使用していますが、会社のメールボックスのクォータを超えていません。私は多くの添付ファイルを取得します。

残りの大きなメールの多くには、「添付ファイル」ではなく画像が埋め込まれていることがわかりました。埋め込み画像で実際に同じこと (ハード ドライブへの保存、電子メールからの削除) を実行できるスクリプトを共有できる人はいますか?

FWIW、これが添付ファイルの取り外しに使用するエージェントです。元の作者への小道具、それが誰だったのかわかりません。

Dim sDir As String
Dim s As NotesSession
Dim w As NotesUIWorkspace
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument

Sub Initialize

    Set s = New NotesSession
    Set w = New NotesUIWorkspace 
    Set db = s.CurrentDatabase
    Set dc = db.UnprocessedDocuments
    Set doc = dc.GetFirstDocument
    Dim rtItem As NotesRichTextItem
    Dim RTNames List As String
    Dim DOCNames List As String
    Dim itemCount As Integer
    Dim sDefaultFolder As String

    Dim vtDir As Variant
    Dim iCount As Integer
    Dim j As Integer
    Dim lngExportedCount As Long
    Dim attachmentObject As Variant
    Dim text As String

    Dim subjectLine As String
    Dim attachmentMoved As Boolean

    ' Prompt the user to ensure they wish to continue extracting the attachments
    Dim x As Integer
    x = Msgbox("V4 This action will extract all attachments from the " & Cstr (dc.Count) &  " document(s) you have selected, and place them into the folder of your choice." & _
    Chr(10) & Chr(10) & "Would you like to continue?", 32 + 4, "Export Attachments")
    If x <> 6 Then Exit Sub 

    ' Set the folder where the attachments will be exported
    sDefaultFolder = s.GetEnvironmentString("LPP_ExportAttachments_DefaultFolder")
    If sDefaultFolder = "" Then sDefaultFolder = "F:"  
    vtDir = w.SaveFileDialog( False, "Export attachments to which folder?", "All files|*.*", sDefaultFolder, "Choose Folder and Click Save")
    If Isempty(vtDir) Then Exit Sub
    sDir = Strleftback(vtDir(0), "\")
    Call s.SetEnvironmentVar("LPP_ExportAttachments_DefaultFolder", sDir) 

    ' Loop through all the selected documents
    While Not (doc Is Nothing)

        iCount = 0
        itemCount = 0
        lngExportedCount = 0
        Erase RTNames
        Erase DocNames

        ' Find all of the RichText fields in the current document.  If any have an embedded object, add the item to the RTNames array.
        Forall i In doc.Items
            If i.Type = RICHTEXT Then
                If Not Isempty(i.EmbeddedObjects) Then
                    'Msgbox i.Name,64,"Has embedded objects"                    
                End If
                Set rtItem = doc.GetfirstItem(i.Name)
                'Set rtItem = i
                If Not Isempty(rtItem.EmbeddedObjects) Then
                    RTNames(itemCount) = Cstr(i.Name)
                    itemCount = itemCount +1
                End If
            End If

        End Forall  

        ' Loop through the RTNames array and see if any of the embedded objects are attachments
        attachmentMoved = False
        For j = 0 To itemCount-1 
            Set rtItem = Nothing
            Set rtItem = doc.GetfirstItem(RTNames(j))
            Forall Obj In rtItem.EmbeddedObjects
                If ( Obj.Type = EMBED_ATTACHMENT ) Then
                    ' The embedded object is an attachment.  Export it to the chosen directory
                    Call ExportAttachment(Obj)

                    ' Append to the bottom of the file details on the extracted file and its new location. 
                    Call rtItem.AddNewline(1)
                    Call rtitem.AppendText("---------------------------------------" + Chr(13) + Chr(10)) 

                    text = """" + sDir + "\"+ Obj.Name + """" + Chr(13) + Chr(10) + Chr(9) + "Extracted by: " + s.UserName + " on " + Str$(Today()) +  ".  "
                    Call rtitem.AppendText(text )               
                    Call rtItem.AddNewline(1)               

                    ' Remove the object from the file and save the document.
                    Call Obj.Remove
                    Call doc.Save( False, True )  'creates conflict doc if conflict exists
                    attachmentMoved = True
                Else
                    Forall verb In Obj.Verbs
                        'Msgbox verb, 64, "VERB"
                    End Forall
                End If 
            End Forall 

            ' If the document had an attachment moved, update the subject line 
            If attachmentMoved = True Then
                Dim item As Notesitem
                Set item = doc.GetFirstItem("Subject")
                subjectLine = item.Text + "- ATTACHMENT MOVED"
                Set item = doc.ReplaceItemValue("Subject", subjectLine)
                Call doc.Save( False, True )  'creates conflict doc if conflict exists
            End If
        Next

        Set doc = dc.GetNextDocument(doc)
    Wend

    Msgbox "Export Complete.", 64, "Finished"

End Sub

Sub ExportAttachment(o As Variant)

    Dim sAttachmentName As String
    Dim sNum As String
    Dim sTemp As String

    ' Create the destination filename
    sAttachmentName = sDir & "\" & o.Source

    ' Loop through until the filename is unique
    While Not (Dir$(sAttachmentName, 0) = "")

        ' Get the last three characters of the filename - "_XX"
        sNum = Right(Strleftback(sAttachmentName, "."), 3)

        ' Ensure the first of the three characters is an underscore and the next two are numeric.  If they are, add one to the existing number and insert it back in.
        If Left(sNum,1) = "_" And Isnumeric(Right(sNum, 2)) Then
            sTemp = Strleftback(sAttachmentName, ".")
            sTemp = Left(sTemp, Len(sTemp) - 2)
            sAttachmentName = sTemp & Format$(Cint(Right(sNum,2)) + 1, "##00") & "." & Strrightback(sAttachmentName, ".")
        Else
            sAttachmentName = Strleftback(sAttachmentName, ".") & "_01." & Strrightback(sAttachmentName, ".")
        End If
    Wend

    ' Save the file
    Call o.ExtractFile( sAttachmentName ) 

End Sub 
4

1 に答える 1

0

MIMEエンコードされた画像は、EmbeddedObjectsプロパティを使用するどのタイプの添付ファイルとしても表示されないため、これはスクリプトで行うと非常に問題があります。

画像がMIMEメッセージの一部としてインラインで保存されている場合、Notesクライアントはそれらを表示用の添付ファイルに変換しますが、プログラムではMIMEメッセージの一部としてのみアクセスできます。(MIMEEntityクラスを使用して)エンコードされたイメージでマルチパートMIMEメッセージの正しい部分を取得し、これをディスクにストリーミングして元のファイルを再構成し、それを表すMIMEEntityを削除する(そしてスペースをアップ)。

に関する詳細情報

IBMサポートサイト

NotesMIMEEntityクラスのドキュメント

于 2011-02-17T04:52:34.200 に答える