Solved

Saving email to files

Posted on 2004-04-24
18
411 Views
Last Modified: 2010-03-23
I would like to save copies of emails send on a project-by-project basis.  For example, to a folder related to a specific client or job.  Is there any practical way to do this?
0
Comment
Question by:GregorySinger
  • 5
  • 5
  • 4
  • +1
18 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 10909750
Create a new folder underneath Inbox based upon the Project/Client information.
You can set up a rule, if there's some identifier with each email to move these automatically to these folders.
If you want to save them to your hard drive - open up your documents folder - create a new folder corresponding to the project/client information.
Set up both your email and document folder where you can see both.  Select all emails from the outlook folder (ctrl + A) - now drag and drop them all into the document folder...
0
 
LVL 7

Expert Comment

by:rosesolutions1
ID: 10910045
That will result in .msg files, which might be fine for your purposes.
I needed files that could be read with Outlook being installed, so wrote code to dump text in txt, rtf in rtf, and html in html (as well as attachments in their native formats). Do you need that?
0
 

Author Comment

by:GregorySinger
ID: 10913846
I may not have been clear enough.  I understood how to save emails received based on folders and rules.  What I'm trying to ask is if there's a way to autmatically save a "carbon-copy" of an outgoing email to a specific folder, representing a client, project, etc?
0
 
LVL 7

Expert Comment

by:rosesolutions1
ID: 10916183
Sure. Are you happy with .msg files, or do you want .txt;.rtf & .html?
(Note: in general, search engines wont search .msg files, so if you want the store to be searchable, you need to check whether yours will search the contents of .msg (and, presumably, the contents of attachments.)
0
 

Author Comment

by:GregorySinger
ID: 10917281
To:  rosesolutions1
Searching the stored messages is not critical, but desireable.
How can I implement your suggestions?
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10917839
>>What I'm trying to ask is if there's a way to autmatically save a "carbon-copy" of an outgoing email to a specific folder, representing a client, project, etc?<<
Do you mean an Outlook folder?  If so, simply apply a rule for all outgoing messages....
0
 

Author Comment

by:GregorySinger
ID: 10924315
Do I mean an Outlook folder?
Actually no.  The reason is that I utilize a "conventional" system file folder to hold a variety of project related items such as spreadsheets (for estimates), Word docs (proposals, etc.), etc. etc.  It would be very helpful to be able to save outgoing copies of emails directly and automatically to such a folder on a project-by-project basis.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10924375
Ew - I was afraid of that....I do a bit of coding myself - but for some reason Outlook's VBA gives me the creeps...
I've got someone in mind that may be able to lend a hand though - I'll try to get a hold of her...stay tuned.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:GregorySinger
ID: 10924506
Much obliged.  Sounds interesting!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10924529
She's extremely sharp - I think I'll hang along for the ride - I just might learn something too.  :D
0
 
LVL 13

Expert Comment

by:stefri
ID: 10926156
GregorySinger, Sirbounty,
It would be a pleasure to help GregorySinger but  rosesolutions1 already offered to post the code to copy outgoing mails to HD. I had seen this post before when published and when Rosesolutions1 popped in, I did not want to interfere...
Neverthelss, whoever works on this project, we will need more info: how to determine that an outgoing mail must be saved to HD? Subject content?

Stefri
BTW: I should sign sir-stefri (Ste is the beginning of my first name Stephane which is equivalent to the Anglo-Saxon first name Steve, Stephen, Stevie...The female first name is Stephanie ;-).
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10927809
My apologies!  I was typing "him" and then changed my mind...not wanting to offend anyone - but alas, looks like I may have after all.  :(
0
 
LVL 13

Expert Comment

by:stefri
ID: 10928705
no problem....once dreamboat wrote I was a doll....
Stefri
0
 

Author Comment

by:GregorySinger
ID: 10935171
Stefri, Rosesolutions1
Stefri: I didn't interpret rosesolutions1 reply as having code to do what I wanted.  If I'm wrong, I apologize.  And rosesolutions1, I'd like to see the code.
Stefri, you also bring up a good point as to how and when to do this copying.  The ideal scenario would be to have some mechanism to flag the code so that the HD file (location)  could be put in the "cc" box, and that would trigger the copying. Or, a special field on a custom email form that when filled in would trigger the copying.
Any others ideas are welcome.  Thanks!
0
 
LVL 7

Expert Comment

by:rosesolutions1
ID: 10935519
If you want a no-code method, then check out the Save Message action of the product InboxRules. <http://www.inboxrules.com/products/engines/rw/>

For a code method, the code below saves a selected email (or group of emails) to disk. Get this bit working, and then we can talk about how to make it automatic...

Sub blulksaveout()
Dim selItems As Outlook.Selection
Dim objItem As Object
Dim x As Long
Dim strPath As String, strFullName As String, strName As String
On Error GoTo myerr

Set selItems = Application.ActiveExplorer.Selection
strPath = InputBox("Where would you like to save the " & selItems.Count & " items selected?" & vbNewLine & "(eg C:\MyFiles)", "Bulk Save Utility", "C:\temp")
If Len(strPath) > 0 Then 'else they hit cancel
    If Right(strPath, 1) = "\" Then strPath = Left(strPath, Len(strPath) - 1) 'catch "C:\"
    For x = 1 To selItems.Count
        Set objItem = selItems.Item(x) 'some of the properties used below are mailitem only
        If TypeName(objItem) = "MailItem" Then
            strName = MakeStringValid(objItem.Subject) 'Format(objItem.SentOn, "yymmdd") & " " &
            Select Case objItem.BodyFormat
                Case olFormatHTML
                    strFullName = strPath & "\" & strName & ".htm"
                    objItem.SaveAs strFullName, olHTML 'olSaveAsType constant for HTML only works if the item is HTML
                Case olFormatPlain
                    strFullName = strPath & "\" & strName & ".txt"
                    objItem.SaveAs strFullName, olTXT
                Case olFormatRichText
                    strFullName = strPath & "\" & strName & ".msg"
                    objItem.SaveAs strFullName
                Case olFormatUnspecified
                    strFullName = strPath & "\" & strName & ".msg"
                    objItem.SaveAs strFullName
            End Select
        End If
        objItem.Delete
xx_Continue:
        Set objItem = Nothing
    Next x
End If
exit_sub:
    Set objItem = Nothing
    Set selItems = Nothing
Exit Sub

myerr: 'std
    Dim intReturn As Integer
    intReturn = MsgBox(Err.Number & " - " & Err.Description, vbAbortRetryIgnore)
    Select Case intReturn
        Case vbAbort
            GoTo exit_sub
        Case vbRetry
            'make debugging invalid character list a bit faster...
'            strName = MakeStringValid(objItem.Subject) 'Format(objItem.SentOn, "yymmdd") & " " &
'            strFullName = strPath & "\" & strName & ".htm"
            Resume
        Case vbIgnore
            Resume xx_Continue
    End Select
End Sub

Function MakeStringValid(StringToTest As String) As String
Const strBadChars As String = "@#$%^&: ?-()'\/"
Dim strInUse As String
strInUse = StringToTest
    Dim x As Integer
    For x = 1 To Len(strBadChars)
    Dim y
        y = Mid$(strBadChars, x, 1)
        If InStr(1, strInUse, y, 0) Then
            strInUse = Replace(strInUse, y, "_")
        End If
    Next x
'untested supplement that we may need later...
'    Const badascii As String = "34091013" 'double quote, tab, line feed, carriage return
'    For x = 1 To Len(badascii) / 2
'        y = Mid$(badascii, x * 2, 2)
'        If InStr(1, strInUse, y, 0) Then
'            strInUse = Replace(strInUse, y, "_")
'        End If
'    Next x
    MakeStringValid = strInUse
End Function
0
 
LVL 7

Accepted Solution

by:
rosesolutions1 earned 250 total points
ID: 10935538
OK - now to identify which ones go where, you can
(a) use outlook categories (unlimited cateogirs, so nice)
(b) use outlook flags (only a restricted set of options)
(c) link the items to Contacts (best outcome bcause adds functionality to Outlook, but may be slowest to do)
(d) store the items in different Outlook folders, and automatically write to disk all the messages that get stored in those folders - how do you organise your inbox?

0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Use email signature images to promote corporate certifications and industry awards.
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

21 Experts available now in Live!

Get 1:1 Help Now