Solved

Software plugin for Outlook

Posted on 2007-03-30
11
232 Views
Last Modified: 2012-06-27
Hi,

does anybody know of software that will do the following:

Users send an email from Outlook (2000 and/or 2003; Exchange account; some remote users are using Outlook using RPC over https)

When a user presses send I'd like this software to ask them would they like to save a copy to a network share.

And if so, specify the location to save the copy of the email.

Different emails relate to different jobs so the network location will change on a per email basis
0
Comment
Question by:darraghcoffey
  • 6
  • 5
11 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 18825142
This is simple enough to do with a bit of scripting?  Is that an option?
0
 

Author Comment

by:darraghcoffey
ID: 18828509
What would that involve?
I haven't done much scripting/programming since College?
I'd be willing to give it a go though.....
0
 
LVL 76

Expert Comment

by:David Lee
ID: 18829554
> What would that involve?
Something like the code below.  This code will fire each time Outlook sends anything.  If the item being sent is a message (as opposed to a meeting request, task request, read receipt, etc.), then the code prompts the user asking if they want to save the message.  If they click "yes", then a dialog-box appears so they can enter the path to save the item to.  To use this code, follow these instructions.

1.  Open Outlook.
2.  Click Tools->Macro->Visual Basic Editor.  You should now be looking at the code editor.
3.  If it's not alread expanded, expand Microsoft Office Outlook Objects.  Then click on ThisOutlookSession.
4.  Copy the code below and paste it into the code window.
5.  Edit the code as needed.  I included a comment line where things can/need to change
6.  Close the code window.
7.  Exit Outlook.
8.  Start Outlook.
9.  You should receive a dialog-box asking if you want to enable macros.  You must enable them for this code to work.  You'll have to do this each time you start Outlook.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim strPath As String
    If Item.Class = olMail Then
        'Change the message on the next line as desired
        If MsgBox("Do you want to save a copy of this message to the file system?", vbYesNo + vbQuestion, "Save Message") = vbYes Then
            'Change the message, caption, and default path on the next line as desired
            strPath = InputBox("Enter the path to the folder where the message will be saved.", "Save Message", "C:\")
            Item.SaveAs strPath & "\" & RemoveIllegalCharacters(Item.Subject) & ".msg", olMSG
        End If
    End If
End Sub

Function RemoveIllegalCharacters(strItem As String) As String
    'This function strips illegal characters from the message subject so the subject can be used as the file name
    Dim strTemp As String
    strTemp = Replace(strItem, ":", "%58")
    strTemp = Replace(strTemp, "/", "%47")
    strTemp = Replace(strTemp, "\", "%92")
    RemoveIllegalCharacters = strTemp
End Function
0
 

Author Comment

by:darraghcoffey
ID: 18849098
BlueDevil,

Thanks a million - that worked a treat!

Now excuse me for being picky but if we could make one (small) improvement it would be absolutlely perfect (if we can make the improvement I'll increase value of question to 500)

1.) Instead of having to manually type in the filepath to save to; can we have an optional Browse button also?
0
 

Author Comment

by:darraghcoffey
ID: 18849186
BlueDevil,

Also what will happen if two emails of same subject are saved to the same location? I haven't tried to do this yet
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 76

Expert Comment

by:David Lee
ID: 18853677
Ok, I'll put together something together that browses for the folder to save to.  In answer to your question, right now the last message will received will overwrite any previous version.  If you want that changed, then how do you want to handle duplicates.
0
 

Author Comment

by:darraghcoffey
ID: 18853951
I suppose if they were to incement  it would be great eg.

EmailSubject.msg; (as it would currently save it)
EmailSubject(2).msg
EmailSubject(3).msg

etc.

Cheers
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 18855190
Ok, replace the code you have now with the code below.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    If Item.Class = olMail Then
        'Change the message on the next line as desired
        If MsgBox("Do you want to save a copy of this message to the file system?", vbYesNo + vbQuestion, "Save Message") = vbYes Then
        SaveMessage Item
    End If
End Sub

Sub SaveMessage(olkMessage As Outlook.MailItem)
    Dim strMacroName As String, _
        strPathName As String, _
        strFilename As String, _
        objTemp As Object, _
        objFSO As Object, _
        intCount As Integer
    strMacroName = "Save Message to File System"
    'Edit the starting folder path on the next line as needed
    strPathName = GetFolderName(InputBox("Enter the starting path.", "Starting Path", "P:\Projects\"))
    If strPathName = "" Then
        MsgBox "No folder selected.  Operation aborted.", vbInformation + vbOKOnly, strMacroName
    Else
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        strFilename = ReplaceIllegalCharacters(olkMessage.Subject) & ".msg"
        Do While True
            If objFSO.FileExists(strPathName & strFilename) Then
                intCount = intCount + 1
                strFilename = ReplaceIllegalCharacters(olkMessage.Subject) & "(" & intCount & ").msg"
            Else
                Exit Do
            End If
        Loop
        olkMessage.SaveAs strPathName & strFilename, olMSG
    End If
    Set objFSO = Nothing
    Set objTemp = Nothing
    Set olkMessage = Nothing
End Sub

Function GetFolderName(strStartingFolder As Variant) As String
    Const WINDOW_HANDLE = 0
    Const NO_OPTIONS = 0
    Dim objShell As Object, _
        objFolder As Object, _
        objFolderItem As Object
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.BrowseForFolder(WINDOW_HANDLE, "Select a folder:", NO_OPTIONS, strStartingFolder)
    If Not TypeName(objFolder) = "Nothing" Then
        Set objFolderItem = objFolder.self
        GetFolderName = objFolderItem.Path & "\"
    Else
        GetFolderName = ""
    End If
    Set objFolderItem = Nothing
    Set objFolder = Nothing
    Set objShell = Nothing
End Function

Function ReplaceIllegalCharacters(strSubject As String) As String
    Dim strBuffer As String
    strBuffer = Replace(strSubject, ":", "")
    strBuffer = Replace(strBuffer, "\", "")
    strBuffer = Replace(strBuffer, "/", "")
    strBuffer = Replace(strBuffer, "?", "")
    strBuffer = Replace(strBuffer, Chr(34), "'")
    strBuffer = Replace(strBuffer, "|", "")
    ReplaceIllegalCharacters = strBuffer
End Function

0
 

Author Comment

by:darraghcoffey
ID: 18856416
Increasing the points of the solution!
0
 

Author Comment

by:darraghcoffey
ID: 18856440
Thanks a million BlueDevil!

Note: For anyone else who wants to use this solution there is one (small) error in the code

You will need to add another End If between lines 7 & 8 in the definition of the Sub_Application

(as is presented in the first code)

Not to take from BlueDevil who is more than worth the 500 points!!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 18856704
You're welcome, and thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Sometimes Outlook might have problems sending a message. There may be various causes- corrupted PST, AV scanner etc. The message, instead of going to the Sent Items folder, sits in the Outbox indefinitely. To remove it you can use a free tool cal…
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
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…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

911 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

25 Experts available now in Live!

Get 1:1 Help Now