?
Solved

auto saving email with same subject heading to server directories

Posted on 2006-07-04
5
Medium Priority
?
240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out what you should include to make the best professional email signature for your organization.
If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

766 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