Home > Domino Tips > Developer > QuickTips > Extract attachments and indicate a new location
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

QUICKTIPS

Extract attachments and indicate a new location


Bil Mcconoughey
01.12.2005
Rating: -4.00- (out of 5)


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


This tip is a modification of the Ken Pespisa's tip Extract attachments from e-mail. After saving the attachment in another directory, the new location is appended to the body of the e-mail so that it's easy to find the next time it's needed.

  Code: Sub Initialize
 Dim sDir As String
 Dim s As NotesSession
 Dim w As NotesUIWorkspace
 Dim db As NotesDatabase
 Dim doc As NotesDocument
 Dim uidoc As NotesUIDocument
 
 Set s = New NotesSession
 Set w = New NotesUIWorkspace 
 Set db = s.CurrentDatabase
 Set uidoc = w.CurrentDocument
 Set doc = uidoc.Document
 Dim rtItem As NotesRichTextItem
 Dim sDefaultFolder As String
 Dim x As Integer
 Dim vtDir As Variant
 Dim j As Integer
 Dim text As String
 Dim text2 As String
 text = ""
 text2 = ""
 
 x = Msgbox("This action will extract all
 attachments from the  document 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 
 
 sDefaultFolder = s.GetEnvironmentString("ExtractAgent")
 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), "Choose Folder and Click Save")
 Call s.SetEnvironmentVar("ExtractAgent",vtDir(0))
 
 Set rtitem = doc.GetFirstItem( "Body" )
 If ( rtitem.Type = RICHTEXT ) Then
  Forall o In rtitem.EmbeddedObjects
   If ( o.Type = EMBED_ATTACHMENT )  
And ( o.FileSize > MAX ) Then
    fileCount = fileCount + 1
    Call o.ExtractFile ( sDir + o.Name )
    Call rtItem.AddNewline(1)
    text = o.Name + " has been moved to " +
 sDir + " by " + s.UserName + " 
on " + Str$(Today()) +  ".  "
    Call rtitem.AppendText("<< " + text + " >>") 
    text2 = text2 + text
    Call rtItem.AddNewline(1)
    Call o.Remove
    Call doc.Save( True, True )
   End If
  End Forall
 End If 
 
 Msgbox text2, 16, "Document(s) Detached"
 Call uidoc.Close
 
End Sub

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip exchange by member Bil McConoughey. Please let others know how useful it is via the rating scale at the end of the tip. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

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
QuickTips
A bevy of Notes/Domino development tips
How to protect your Lotus Notes application design
Merging views
Stop an agent without shutting down the Amgr task
Collapsing outlines
How to make Notes view icons run code
Find all databases associated with a template
Verifying user's date setting and time zone on local PC
Load design for a single database
Options for changing passwords

Lotus Notes Domino Coding and Development
Tutorial: 30 LotusScript tips
A bevy of Notes/Domino development tips
A Formula language for Lotus Notes introduction -- 7 tips in 7 minutes
Top 10 Notes/Domino developer tips of 2006
Sending and logging faxes from Lotus Notes and Domino
Accessing documents in a Lotus Notes database
A smorgasbord of Notes/Domino development tips
Creating a Lotus Notes view column categorized by month
A project-tracking application for Lotus Notes Domino
What the new Office means for developers

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 enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




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