Solved

auto saving email with same subject heading to server directories

Posted on 2006-07-04
5
231 Views
Last Modified: 2010-04-08
not sure exactly what category this should come under but i'll start here. I have a user who gets a lot of email from newsgroups. he saves these to general directories on a win2k3 server. we no longer maintain our exchange/public folders for this so he has to store these on one of our servers so others can search through them. a solution we need is one that can overcome the issue of saving messages that have the same subject heading to directories versus moving them to exchange public folders (which was a lot easier). Outlook seems limited in it's rules language to accomplish this.
0
Comment
Question by:demus619
  • 3
  • 2
5 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 17038289
Hi demus619,

This would require some VBA code that would check to see if a file with a matching name already exists and, if so, rename it or append a sequence number to it.  I can post code for doing this if this sounds like an option.

Cheers!
0
 

Author Comment

by:demus619
ID: 17043202
sure, post it, would be worth viewing and appreciated it.  
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 17046875
Ok, here it is.  This macro can be hooked directly to a rule.  When the rule fires it triggers the macro which saves the message to disk using the subject as the file name.  If a file with that name already exists in the save to folder, then the code will add "(1)" to the file name and attempt to save it again.  If that file name has already been used, then it'll change "(1)" to "(2)" and try again.  It will keep adding one to the number until there is no matching file at which point the message is saved with that name.  There is one hitch to this process.  Saving a message to disk is going to trigger Outlook's built in security, causing a dialog-box to pop up warning that a program is accessing your mailbox and asking for permission to allow it to continue.  There are four ways around this.

1.  Sign the code using a digital certificate.  If you don't have a certificate, then you can use a self-cert.  Here are instructions for doing that: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnoxpta/html/odc_dsvba.asp

2.  Use Click-Yes.  This is a small utility that sits in the system tray and clicks the "yes" button for you when Outlook's security pop-up appears.  http://www.contextmagic.com/express-clickyes/

3.  Outlook Redemption.  This is a DLL that safely circumvents Outlook security.  The code would have to be re-written to use Redemption.  http://www.dimastr.com/redemption

4.  Re-write the code to be an Outlook add-in.  Add-ins have different security rules.  THey are also more difficult to write.

Follow these instructions to use the code.

1.  Start Outlook
2.  Click Tools->Macro->Visual Basic Editor
3.  If not already expanded, expand Modules and click on Module1
4.  Copy the code below and paste it into the right-hand pane of the VB editor window
5.  Edit the code as needed.  I placed comment lines where things need to be changed
6.  Click the diskette icon on the toolbar to save changes
7.  Close the VB Editor
8.  Click Tools->Macro->Security
9.  Set the Security Level to Medium
10.  Create a new rule.
11.  Set the rule to fire on every message
12.  Set the rule's action to "run a script"
13.  Select the macro named Module1.SaveMessageToFileSystem as the target script

Sub SaveMessageToFileSystem(Item As Outlook.MailItem)
    Dim strSaveToPath As String, _
        strFilename As String, _
        intCount As Integer, _
        objFSO As Object
    'Change the path on the following line
    strSaveToPath = "C:\eeTesting\"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    strFilename = Replace(Replace(Item.Subject, ":", ""), "\", "")
    intCount = 1
    Do While True
        If objFSO.FileExists(strSaveToPath & strFilename & ".txt") Then
            strFilename = objFSO.GetBaseName(Item.Subject) & "(" & intCount & ")"
            intCount = intCount + 1
        Else
            Item.SaveAs strSaveToPath & strFilename & ".txt", olTXT
            Exit Do
        End If
    Loop
    Set objFSO = Nothing
End Sub
0
 

Author Comment

by:demus619
ID: 17048104
OK, thanks. i will test this tomorrow at work and assign points then. Opts 1 & 2 look practical for us. I'll get back to  you tomorrow. thanks!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 17055003
You're welcome.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Set OWA language and time zone in Exchange for individuals, all users or per database.
Use email signature images to promote corporate certifications and industry awards.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now