Solved

Move email to folder, need to display more than subject as filename

Posted on 2004-10-14
8
297 Views
Last Modified: 2011-10-03
OK, here is what im doin...  need to move emails from my inbox to a folder on my hard drive.   When I just click and drag the emails it works fine, but it changes the file name to the subject.  I would need to display at least sender and subject as filename.

Any ideas?

I can not find any settings to change this, but I'm sure I'm just looking in the wrong place.

Thanks!
0
Comment
Question by:skwash
  • 4
  • 3
8 Comments
 
LVL 15

Accepted Solution

by:
will_scarlet7 earned 125 total points
ID: 12317721
I think you will need to have a MACRO to save the items via code. The following MACRO will save all the mail items in a selected folder to C:\temp, with the file name formated as "From - (SenderName) - (Subject).msg

Sub SaveAsOlMSG()
   
    'Declare Objects & Variables
    Dim oOutlook As Outlook.Application
    Dim oNs As Outlook.NameSpace
    Dim oFldr As Outlook.MAPIFolder
    Dim oMessage As Object
    Dim oSfMsg As Redemption.SafeMailItem
    Dim oMBox As String
    Dim oSubject As String
    Dim oSbjAlpha As String
    Dim ctr As Integer
   
    'Setup the object variables
    Set oOutlook = New Outlook.Application
    Set oNs = oOutlook.GetNamespace("MAPI")
    oMBox = MsgBox("Select the folder containg the message items you wish to save:", vbOKOnly)
    Set oFldr = oNs.PickFolder
    Set oSfMsg = CreateObject("Redemption.SafeMailItem")

oSfMsg.AuthKey = "str8isTheg8"

    For Each oMessage In oFldr.Items
            oSfMsg.Item = oMessage
            ctr = 1
            oSbjAlpha = ""
            While ctr < (Len(oSfMsg.Subject) + 1)
                If Mid(oSfMsg.Subject, ctr, 1) Like "[A-Za-z( )]" Then
                    oSbjAlpha = oSbjAlpha & Mid(oSfMsg.Subject, ctr, 1)
                ElseIf Val(Mid(oSfMsg.Subject, ctr, 1)) > 0 Then
                    oSbjAlpha = oSbjAlpha & Mid(oSfMsg.Subject, ctr, 1)
                ElseIf Mid(oSfMsg.Subject, ctr, 1) = "0" Then
                    oSbjAlpha = oSbjAlpha & Mid(oSfMsg.Subject, ctr, 1)
                ElseIf Mid(oSfMsg.Subject, ctr, 1) = "." Then
                    oSbjAlpha = oSbjAlpha & Mid(oSfMsg.Subject, ctr, 1)
                Else
                    oSbjAlpha = oSbjAlpha & " "
                End If
                ctr = ctr + 1
            Wend
            oSfMsg.SaveAs "C:\Temp\From - " & oSfMsg.SenderName & " - " & oSbjAlpha & ".msg", olMSG
            'oMessage.Move oToFldr
    Next oMessage
   
    Set oOutlook = Nothing
    Set oNs = Nothing
    Set oFldr = Nothing
    Set oSfMsg = Nothing
   

End Sub
0
 

Author Comment

by:skwash
ID: 12321426
I think you are probably right but  I am getting an error saying "compile error: user defined type not defined"  

This happens at:

    Dim oSfMsg As Redemption.SafeMailItem

I'm running Outlook 2003 if that makes a difference.  I have never created macro's in outlook so mabey I'm doing something wrong
0
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 12321491
Sorry about that... I forgot to mention that in order to avoid the security warnings that outlook will throw when you save an email to disk via code I used the Outlook Redemption library. You can download Outlook Redemption from here:
http://www.dimastr.com/redemption/

If you install that (And set a reference to "SafeOutlook Library") it should run without the error. You will also need to delete the line that says:

    oSfMsg.AuthKey = "str8isTheg8"

That line is custom specific to my setup but not required on a clean setup of Outlook Redemption.
0
 

Author Comment

by:skwash
ID: 12321711
Awesome...  looks like it will work...  I'm gonna have to make some tweaks to the code to meet our needs but this looks great!

thanks for the help!
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:skwash
ID: 12321850
how would I delete the mail after it has been moved to the folder?

thx
0
 

Author Comment

by:skwash
ID: 12322564
nevermind, just added oMessage.delete :P
0
 
LVL 4

Expert Comment

by:Gal_atea
ID: 12323972
Glad I could help Skwash!
God bless!

Sam
0
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 12323984
Oops... Sorry... I was using my Girlfriend's computer.

ThanX!

Sam
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
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…
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…

757 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

19 Experts available now in Live!

Get 1:1 Help Now