Home > Domino Tips > Administrator > Mail > Detach from migrated mail
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

MAIL

Detach from migrated mail


Fredrik Malmborg
01.19.2001
Rating: --- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


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.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Mail
Run or restart Notes/Domino agents via text messages
How to create mail files using a LotusScript agent
How to turn off the message recall feature in Lotus Notes 8
Domino server setting and email policy tricks admins must know
Top 10 Lotus Notes/Domino administration tips of 2008
Understanding a Lotus Notes Smart Upgrade rollout
Bringing MailRule documents back into view
Use SMTP outbound authentication to relay hosts in Lotus Notes Domino 8
Notes/Domino 6 version of 'Discover Folder'
Five tips to improve email performance

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

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.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts