
MAIL
Detach from migrated mail
Fredrik Malmborg 01.19.2001
Rating: --- (out of 5)




|
A college at my company could not open a mail that once was imported from Exchange. The mail contained a lot of files that he really needed. I wrote an agent that detaches all files from the selected document to c:detached.
Some of the code I found at Searchdomino.
Code: Sub Click(Source As Button)
Dim session As New NotesSession
Dim collection As NotesDocumentCollection
Dim Db As NotesDatabase
Dim doc As NotesDocument
Dim NFiles As Integer
Dim Path As String
Dim OutFiles As Variant
Set Db = session.CurrentDatabase
Set collection = Db.UnProcessedDocuments
Set doc = collection.GetFirstDocument
Path="C:Detached"
OutFiles=""
NFiles=GetAllAttachments(doc, Path, OutFiles)
End Sub
Function GetAllAttachments ( Doc As Notesdocument, Path As String , OutFiles As Variant ) As Integer
' This function detaches all the File Attachments in the input Doc and stores them in the path specified (if incorrect it saves in c:temp)
' It returns 0 if not attachements found
' else it returns the number of attachements in the documents also all the detached file names will be stored in the parameter string Outfiles
On Error Goto ErrorPara
If path = "" Then
path = "C:Temp"
Elseif Instr(path,":") = 0 Then
path = "C:Temp"
Elseif Instr(path,"") = 0 Then
path = "C:Temp"
Elseif ( Right(path,1) < > "" ) Then
path = "C:Temp"
Elseif Mid(path , 2 , 2) < > ":" Then
path = "C:Temp"
End If
OutFiles = ""
GetAllAtachments = 0
If Not ( Doc.HasEmbedded) Then
Exit Function
End If
Dim n As Integer
Dim flname As String
n = 0
flname = ""
Dim rtitem As Variant
Forall Item In doc.items
If item.name = "$FILE" Then
'Filname=item.Source
Set object = doc.GetAttachment( item.values(0) )
n = n+1
Print "Detaching File # " + Cstr(n) + " : " + Path+Cstr(object.name)
Call object.ExtractFile( Path & Cstr(object.name) ) 'Observe that the path must exist on the disk.
flname = flname + Path+Cstr(object.name) +";"
End If
End Forall
OutFiles = Evaluate(|@Explode("|+flname+|" ; ";")|)
GetAllAttachments = n
Print Cstr(n) + " files have be detached !"
Exit Function
ErrorPara:
Print " Error Occured in GetAllAttachments : " + Cstr(Err())+ Error$
Exit Function
End Function
 |

|
Rate this Tip
|
To rate tips, you must be a member of SearchDomino.com. Register now
to start rating these tips. Log in if you are already a member.
|


');
// -->
DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.
|
 |
|
|
 |
|
 |