Lotus notes LotusScript无法从电子邮件获取文件附件
我从未遇到过这个问题,但我无法处理电子邮件上的文件附件。我的代码可以在文档中搜索嵌入的对象,也可以在字段中搜索嵌入的对象——它们都不会返回文件。我可以看到电子邮件上的文件,也可以看到包含文件附件的$file字段 代码如下:Lotus notes LotusScript无法从电子邮件获取文件附件,lotus-notes,mime,lotus-domino,lotusscript,richtext,Lotus Notes,Mime,Lotus Domino,Lotusscript,Richtext,我从未遇到过这个问题,但我无法处理电子邮件上的文件附件。我的代码可以在文档中搜索嵌入的对象,也可以在字段中搜索嵌入的对象——它们都不会返回文件。我可以看到电子邮件上的文件,也可以看到包含文件附件的$file字段 代码如下: Function FileDetachFiles(doc As NotesDocument, fieldName As String, getFromField As Integer) As Variant On Error Goto ProcessErro
Function FileDetachFiles(doc As NotesDocument, fieldName As String, getFromField As Integer) As Variant
On Error Goto ProcessError
Dim s As NotesSession
Dim db As NotesDatabase
Dim rtItem As NotesRichTextItem
Dim fileToExtract As String
Dim fileName As String
Dim fileArray() As String
Dim message As String
Dim embedObjects As Variant
Dim attachFile As Integer
Dim x As Integer
Set s = New NotesSession
Set db = s.CurrentDatabase
Const fileImport = "C:\"
attachFile = False
'Let's see if there are attached files...
If getFromField = True Then
'Locate field and get files...
If doc.HasEmbedded Then
If doc.HasItem(fieldName) Then
'Set the first field...
Set rtItem = doc.GetFirstItem(fieldName)
embedObjects = rtItem.EmbeddedObjects
If Isarray(embedObjects) Then
Forall Files In rtItem.EmbeddedObjects
If Files.Type = EMBED_ATTACHMENT Then
fileName = Files.Source
fileToExtract = fileImport & fileName
Redim Preserve fileArray(x)
fileArray(x) = fileToExtract
x = x + 1
Call Files.ExtractFile(fileToExtract)
attachFile = True
End If
End Forall
End If
End If
End If
Else
x = 0
'Go through doc looking for all embedded objects...
If doc.HasEmbedded Then
Forall o In doc.EmbeddedObjects
If o.Type = EMBED_ATTACHMENT Then
fileName = o.Name
fileToExtract = fileImport & fileName
Call o.ExtractFile(fileToExtract)
Redim Preserve fileArray(x)
fileArray(x) = fileToExtract
x = x + 1
attachFile = True
End If
End Forall
End If
End If
If attachFile = True Then
FileDetachFiles = fileArray
End If
Exit Function
ProcessError:
message = "Error (" & Cstr(Err) & "): " & Error$ & " on line " & Cstr(Erl) & " in GlobalUtilities: " & Lsi_info(2) & "."
Messagebox message, 16, "Error In Processing..."
Exit Function
End Function
我尝试了上面的两个例程——传递$FILE和Body字段名,以及搜索文档。它找不到任何文件附件
我甚至试过:
在文档中找不到任何MIME
我从来没有遇到过这样的问题——任何想法都会很好
谢谢 我以前就有过,但不幸的是,我不记得它是从哪里来的,它可能需要处理来自Domino网站的V2风格的附件。。。 尝试求值(@AttachmentNames)以获取包含所有附件名称的变量。然后使用Forall-loop循环完成这个过程,并尝试NotesDocument.getAttachment(strLoopValue)-函数获取附件的句柄。 有关更多信息,请阅读并遵循该页面上的链接,尤其是 代码应该是这样的:
Dim doc as NotesDocument
Dim varAttachmentNamens as Variant
Dim object as NotesEmbeddedObject
REM "Get the document here"
varAttachmentNames = Evaluate( "@AttachmentNames" , doc )
Forall strAttachmentName in varAttachmentNames
Set object = doc.GetAttachment( strAttachmentName )
REM "Do whatever you want..."
End Forall
成功了,谢谢!下面是我最后的代码:attachNames=Evaluate(@AttachmentNames),用于attachNames中的所有值attachName=values Set object=doc.GetAttachment(attachName)If object.Type=EMBED\u ATTACHMENT然后fileName=object.Name fileToExtract=fileImport&fileName调用object.extract文件(fileToExtract)Redim Preserve fileArray(x)fileArray(x)=fileToExtract x=x+1 End If End for all